Hacker News new | past | comments | ask | show | jobs | submit login

No, it wasn't. I added map(str.upper, xxx), now it does.



Then again a lazy map is just an import away in P2. It removes pitfalls from Python but the improvement is… very limited (as opposed to e.g. `yield from` which is a big convenience, or for much more specialised uses the ellipsis literal being universal)


  (process(line.upper()) for line in open('giantfile.txt') if line.lstrip()[0] != '#')


That's besides the point. It's trivial to write that as a for loop or in a million different ways to avoid the issue. It's a contrived example written to demonstrate a difference.

Here's another one you can't change that easily:

    tests_pass = all(process(input) == output for (input, output) in zip(open('inputs.txt'), open('outputs.txt'))


You can change that easily, with izip from itertools.

The fact that a bunch of builtins and the values/items methods of dictionaries have become iterators is not very siginificant IMHO. Python 2 code could already be written to use iterators or generator expressions, so in the parts where it was crucial it was already done. In this regard Python 3 has not added new functionality but only changed defaults.

The unicode change is the big one.


In this case (checking that process(input) == output), itertools.izip_longest is probably that right solution, unless there's an out-of-band way to know that inputs.txt is the same length as outputs.txt.


You felt the need to correct yourself earlier, so I think your "besides the point" should be directed to yourself. I was pointing out that your correction wasn't persuasive.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: