https://pyformat.info/
s = '%s %s' % ('one', 'two')
Learn Python Easy Way
Thursday, September 7, 2017
what is base64
https://en.wikipedia.org/wiki/Base64
- It is a binary to text encoding scheme. Each base64 digit represents exactly 6 bits of data, this is why 2^6 = 64 - the scheme is called base64.
- It is a binary to text encoding scheme. Each base64 digit represents exactly 6 bits of data, this is why 2^6 = 64 - the scheme is called base64.
Friday, September 1, 2017
jenkins access using REST API
BitBucket authenticated Jenkins:
:Disabling ssl verication: [SSL: CERTIFICATE_VERIFY_FAILED]
http://tims.io/disabling-ssl-verification-in-python-jenkins-api/
- Find API Token using:
https://ci.automationanywhere.net/user/aagopalsingh/configure
http://your.jenkins.server/<user_id>/configure
from jenkinsapi.jenkins import Jenkins
from jenkinsapi.utils.requester import Requester
import requests
requests.packages.urllib3.disable_warnings()
jenkins = Jenkins(url, requester=Requester(username, password, baseurl=url, ssl_verify=False))
:Disabling ssl verication: [SSL: CERTIFICATE_VERIFY_FAILED]
http://tims.io/disabling-ssl-verification-in-python-jenkins-api/
- Find API Token using:
https://ci.automationanywhere.net/user/aagopalsingh/configure
http://your.jenkins.server/<user_id>/configure
from jenkinsapi.jenkins import Jenkins
from jenkinsapi.utils.requester import Requester
import requests
requests.packages.urllib3.disable_warnings()
jenkins = Jenkins(url, requester=Requester(username, password, baseurl=url, ssl_verify=False))
Thursday, August 31, 2017
python function decorators
https://realpython.com/blog/python/primer-on-python-decorators/
https://www.thecodeship.com/patterns/guide-to-python-function-decorators/
https://www.learnpython.org/en/Decorators
decorators dynamically alter the functionality of a function, method, or class
This is ideal when you need to extend the functionality of functions that you don't want to modify.
Things to know for understanding the decorators:
- assign function to a variable:
def f():
print 'ok'
a = f
a()
- define function inside other function (sub function in a function, and the sub function is called):
- Function as parameter:
def a():
return 'HELLO'
def b(fun):
return str(fun()) + 'HI;
b(a)
https://www.thecodeship.com/patterns/guide-to-python-function-decorators/
https://www.learnpython.org/en/Decorators
decorators dynamically alter the functionality of a function, method, or class
This is ideal when you need to extend the functionality of functions that you don't want to modify.
Things to know for understanding the decorators:
- assign function to a variable:
def f():
print 'ok'
a = f
a()
- define function inside other function (sub function in a function, and the sub function is called):
- Function as parameter:
def a():
return 'HELLO'
def b(fun):
return str(fun()) + 'HI;
b(a)
range and xrange
http://www.geeksforgeeks.org/range-vs-xrange-python/
range() – This returns a list of numbers created using range() function.
xrange() – This function returns the generator object that can be used to display numbers only by looping. Only particular range is displayed on demand and hence called “lazy evaluation“.
memory used for xrange is much less compared to range
range() – This returns a list of numbers created using range() function.
xrange() – This function returns the generator object that can be used to display numbers only by looping. Only particular range is displayed on demand and hence called “lazy evaluation“.
memory used for xrange is much less compared to range
python control flow if elif else
a = 5
>>> a=7
>>> if a==5: print 5
... elif a==6: print 6
... else: print 0
...
0
>>> a=7
>>> if a==5: print 5
... elif a==6: print 6
... elif a==7: print 7
... else: print 0
...
7
>>> a=8
>>> if a==5: print 5
... elif a==7: print 7
... elif a==6: print 6
... else: print 0
...
0
>>> a=7
>>> if a==5: print 5
... elif a==6: print 6
... else: print 0
...
0
>>> a=7
>>> if a==5: print 5
... elif a==6: print 6
... elif a==7: print 7
... else: print 0
...
7
>>> a=8
>>> if a==5: print 5
... elif a==7: print 7
... elif a==6: print 6
... else: print 0
...
0
Subscribe to:
Posts (Atom)