26. Простой, но не упрощенный «Python has the potential of being an exceptionally productive language» Bruce Eckel, author of «Thinking in Java» and «Thinking in C++»
53. Alioth shootout — бенчмарки для различных языков http://shootout.alioth.debian.org/
54. Пример: mercurial def findpossible(cmd, table, strict=False): """ Return cmd -> (aliases, command table entry) for each matching command. Return debug commands (or their aliases) only if no normal command matches. """ choice = {} debugchoice = {} for e in table.keys(): aliases = e.lstrip( "^" ).split( "|" ) found = None if cmd in aliases: found = cmd elif not strict: for a in aliases: if a.startswith(cmd): found = a break if found is not None: if aliases[0].startswith( "debug" ) or found.startswith( "debug" ): debugchoice[found] = (aliases, table[e]) else : choice[found] = (aliases, table[e]) if not choice and debugchoice: choice = debugchoice return choice
55. Стиль x = [1, 2, 3, 4] y = [ 'first' , 'second' , 'third' , 'forth' ] # желаем получить z = {1: 'first', 2: 'second', ...} z = {} for i in range ( len (x)): z[x[i]] = y[i] Но лучше так: z = {} for key, value in zip (x, y): z[key] = value А еще лучше: z = dict ((key, value) for key, value in zip (x, y))
56. Ненавязчивый ООП class Foo: """ Description of class """ def __init__( self , arg): """ Foo constructor: `arg`: some arg """ self.value = arg def method(self, value=None): """ Foo method: `value` (optional), default is None """ return self.value*5 def __str__(self): return str (self.value)
57. Скорость разработки Программирование со скоростью мысли. Ты не продумаешь отдельно алгоритм, отдельно как изобразить в коде. Алгоритм сразу формулируется в виде кода, тебе остается просто записать его.