On Thu, May 5, 2016, at 07:46 PM, Dan Sommers wrote: > On Thu, 05 May 2016 18:37:11 -0700, Stephen Hansen wrote: > > > ''.join(x for x in string if x.isupper()) > > > The difference is, both filter and your list comprehension *build a > > list* which is not needed, and wasteful. The above skips building a > > list, instead returning a generator ... > > filter used to build a list, but now it doesn't (where "used to" means > Python 2.7 and "now" means Python 3.5; I'm too lazy to track down the > exact point(s) at which it changed):
Oh, didn't know that. Then again the OP was converting the output of filter *into* a list, which wasted a list either way. -- Stephen Hansen m e @ i x o k a i . i o -- https://mail.python.org/mailman/listinfo/python-list