Trying to decide between PHP and Python
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Tue Jan 4 16:31:56 EST 2011
On Tue, 04 Jan 2011 13:09:13 -0800, Alex Willmer wrote:
> You could also combine this into one line:
>
> import os
> filenames_lower = [fn.lower() for fn in os.listdir('.')]
That's two lines :)
Here are a couple of nicely obfuscated one-liners:
[name.lower() for name in __import__('os').listdir('.')]
map(str.lower, __import__('os').listdir('.'))
--
Steven
More information about the Python-list
mailing list