Thursday, August 13, 2015

expand list to function arguments

http://stackoverflow.com/questions/7745952/python-expand-list-to-function-arguments

Note: A list is not expanded as arguments by itself.

def a(b,c):
    print(b)

d = [2,3]
a(d) : Will not work because the given list is not expanded.

a(*d) will work: see https://docs.python.org/2/tutorial/controlflow.html#unpacking-argument-lists

i18n in python

Internationalization is also called "i18n" (I-eighteen-N): There are 18 letters between I and N in "internationalization.

python has a package called i18n package to support internationalization.

https://pypi.python.org/pypi/python-i18n/0.3.0

git command with [ ]: git -c i18n.logoutputencoding='UTF-8' branch

git -c i18n.logoutputencoding='UTF-8' branch


% in python

http://stackoverflow.com/questions/997797/what-does-s-mean-in-python


It is a string formatting syntax (which it borrows from C).

print("my name is: %s" % 'hello')   : is same as
printf("my name is: %s", "hello")   : % = , of C

tuples and list

A tuple is a sequence of immutable Python objects. Tuples are sequences, just like lists. The differences between tuples and lists are, the tuples cannot be changed unlike lists and tuples use parentheses, whereas lists use square brackets.


immutable Python objects: once created their value never changes.

python tuples

http://www.tutorialspoint.com/python/python_tuples.htm

To write a tuple containing a single value you have to include a comma, even though there is only one value −

tup1 = (50,);