sorted(), reversed(), enumerate(), any(), all() and the python3 version of zip() • Standard library: collections, itertools, lru_cache • Language features: key-functions, and generator expressions • Optimizations: peephole optimizer, length-hint, fast sum, etc. Python Instructor Ø Adconion, Cisco, HP, EBay, Paypal, … Python evangelist and former PSF Board Member
Rapid Development Cycle • Economy of Expression • Readability and Beauty • One way to do it • Interactive Prompt • Batteries Included • Protocols -- wsgi, dbapi, …
tree for all duplicate files import os, hashlib, pprint hashmap = {} # content signature -> list of filenames for path, dirs, files in os.walk('.'): for filename in files: fullname = os.path.join(path, filename) with open(fullname) as f: d = f.read() h = hashlib.md5(d).hexdigest() filelist = hashmap.setdefault(h, []) filelist.append(fullname) pprint.pprint(hashmap)
pseudo code It contributes to Python’s clean, uncluttered appearance It was an audacious move One of the secrets to debugging C is to run it through a beautifier so the indentation will reflect the actual logic, instead of the programmers intended logic With Python, the indentation is executable so the visual appearance and actual execution always match.
holds the language together • Iterables: strings, lists, sets, dicts, collections, files, open urls, csv readers, itertools, etc • Things that consume iterators: for-loops, min, max, sorted, sum, set, list, tuple, dict, itertools • Can be chained together like Unix pipes and filters
most loved language features • Very popular addition to Python • Derived from notation used in mathematics • Clean and beautiful • Much more flexible and expressive than map, filter, and reduce
adds the YIELD keyword Remembers state between invocations: the stack including open loops and try- statements; the execution pointer; and local variables
locks, etc. • More importantly, it is a tool for factoring code • Factors-out common setup and teardown code • Few languages currently have a counterpart to the with-statement
it means to be a sequence, mapping, etc Ability to override isinstance() and issubclass() Ø The new duck-typing, “if it says it’s a duck …” Mix-in capability
= lst = [] for value in iterable: if value not in lst: lst.append(value) def __iter__(self): return iter(self.elements) def __contains__(self, value): return value in self.element def __len__(self): return len(self.elements)
Barry, Effbot, Nick, Ka-Ping, Glyph • Frank Wierzbicki, Armin Rigo, Maciej Fijalkowski, Armin Ronacher, Alex Martelli, Wes McKinney and Jacob Kaplan-Moss • http://hg.python.org/committers.txt Young rising superstars: • Benjamin Peterson • Jessica McKellar • Alex Gaynor Talent