Commits

Victor Stinner committed 7a10922

TODO

Comments (0)

Files changed (1)

 
 other:
 
+ - SetComp, DictComp:
+
+   * {x for x in "abc"} => {"a", "b", "c"}
+   * {x for x in a} => set(a)
+   * {x: y for x, y in a} => dict(a)
+
+ - operator module:
+
+   * lambda x: x[1] => operator.itemgetter(1)
+   * lambda x: x.a => operator.attrgetter('a')
+   * lambda x: x.f('a', b=1) => operator.methodcaller('f', 'a', b=1)
+
  - Python 3.2+: x in (1, 2, 3) => x in {1, 2, 3}, set converted to frozenset
    by the peepholer
  - {1,2}|{3} => {1, 2, 3}
  - Python 2: from __future__ import divison
  - [x*2 for x in range(3)]
- - [f(x) for x in a] => map(f, a) / list(map(f, a))
- - (f(x) for x in a) => itertools.map(f, a) / map(f, a) ? scope ?
+ - map, itertools.map, filter:
+
+   * [f(x) for x in a] => map(f, a) / list(map(f, a))
+   * (f(x) for x in a) => itertools.map(f, a) / map(f, a) ? scope ?
+   * (x for x in a if f(x)) => filter(f, a)
+   * (x for x in a if not f(x)) => __builtin_filternot__(f, a) ?
+   * (2 * x for x in a) => map((2).__mul__, a)
+   * (x for x in a if x in 'abc') => filter('abc'.__contains__, a)
+
  - enable pythonbin by default?
  - not not not x
  - 1 < 2 < 3
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.