3 ms·
> Such as filter keeping the type. In 3 it returns an iterator. > >>> filter(lambda x: x in 'ABC', 'ABCDEFA') > 'ABCA' it was a special case for a few ty
by masklinn 11y ago
> Such as filter keeping the type. In 3 it returns an iterator.
> >>> filter(lambda x: x in 'ABC', 'ABCDEFA')
> 'ABCA'
it was a special case for a few types, didn't (couldn't) work for all types e.g.
>>> filter(lambda x: x in 'ABC', set('ABC'))
['A', 'C', 'B']
> Also, I like print.
I like Python 3's print. It's kind-of a pain because my day-to-day uses Python 2 and the context switch is annoying, but 3's is way more flexible and readable:
print <<f, foo, bar # (or is it >>file? I can never remember)
versus
actually makes sense, no sigil soup
||
\/
print(foo, bar, file=f, flush=True)
/\
||
separate statement necessary in P2
and because it's an expression it can be used in more context than Python 2's print statement.
I feel you on the loss of argument unpacking, it was a very convenient feature (though not too common IME)
- deleted 11y ago[deleted]
- Twirrim 11y agoIn case you haven't seen it, in Python 2.7: >>> from __future__ import print_function >>> print("hi") hi >>> My team is starting to use it as we look to migrate various command line utilities to python 3.