d = dict(x=1)Is transformed to
if d.has_key("x"):
print "yes"
else:
print "no"
d = dict(x=1)(Yes. There are 13 spaces between the d and the :.) The code is checked into the Python sandbox under refactor. I had a bunch of helpful conversations and did a little pair programming with Martin von Loewis.
if "x" in d :
print "yes"
else:
print "no"
Guido wrote a summary post about the Python 3000 sprint work. Update: I fleshed out many of the details in several subsequent posts.
- Python 3000 Translation Strategy describes how to decorate an AST with concrete tokens.
- Python tokenize module explains some details of the tokenize and untokenize functions I'm using.
- An example code transformation describes how the simple has_key() to in transformer works.
1 comment:
There were 13 spaces between the d and the colon in the original code.
Post a Comment