Entries from 2013-11-20 to 1 day

Python str.format

str.format Pro: flexible format Con: this is not common interface for programmer who is familiar with other language Eg >>> "{0} is good. {1} is better! {2} is awesomeXDDDD".format('foo', 'bar', 'baz') 'foo is good. bar is better! baz is a…

Magic method


for else

for ... else statement else is executed only for is finished all range. Pro: Flag can be omitted.Eg1 for i in range(1, 10): print i if i == 11: break else: print "do else" out put >>> ================================ RESTART ==============…