Re:Improving your (Python) code with modern idioms
by mturmon on Tuesday May 08, 2012 @03:23PM
(#3945382)
Maybe you both have a point. Code you wrote for Python 1.6 (1998) could still look like normal Python.
But, code I write now for Python 2.7 looks very different. I use:
list comprehensions
sets
with...as
yield
new "collections" classes like Counter
looping constructs like enumerate and zip
It's true that you could implement the last two in Python 1.6. But the first four are new language constructs. And list comprehensions, in particular, can be sprinkled all around, not just localized like with/as and yield.
In short, the language has grown. Old stuff looks OK, new stuff looks new.
But, code I write now for Python 2.7 looks very different. I use:
list comprehensions sets with...as yield new "collections" classes like Counter looping constructs like enumerate and zip
It's true that you could implement the last two in Python 1.6. But the first four are new language constructs. And list comprehensions, in particular, can be sprinkled all around, not just localized like with/as and yield.
In short, the language has grown. Old stuff looks OK, new stuff looks new.