On Sun, Feb 3, 2019 at 10:36 AM Ben Rudiak-Gould <benrud...@gmail.com> wrote: > > On Sat, Feb 2, 2019 at 3:23 PM Christopher Barker <python...@gmail.com> wrote: >> >> a_list_of_strings.strip().lower().title() >> >> is a lot nicer than: >> >> [s.title() for s in (s.lower() for s in [s.strip(s) for s in >> a_list_of_strings])] >> >> or >> >> list(map(str.title, (map(str.lower, (map(str.strip, a_list_of_strings)))) # >> untested > > In this case you can write > > [s.strip().lower().title() for s in a_list_of_strings]
What if it's a more complicated example? len(sorted(a_list_of_strings.casefold())[:100]) where the len() is supposed to give back a list of the lengths of the first hundred strings, sorted case insensitively? (Okay so it's a horrible contrived example. Bear with me.) With current syntax, this would need multiple map calls or comprehensions: [len(s) for s in sorted(s.casefold() for s in a_list_of_strings)[:100]] (Better examples welcomed.) ChrisA _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/