On 9/5/2011 5:32 PM, Jon Redgrave wrote:
Am I missing something obvious?

ls | python -c "for line in __import__('sys').stdin: print (line.upper())"

Ah, so I am missing something - it is possible - but 'obvious'?
Do people think it should be more accessible

__import__ is well-documented and is listed in the index of the builtin functions chapter. "Direct use of __import__() is rare, except in cases where you want to import a module whose name is only known at runtime." could be explanded to include "or where you want to import as part of an expression"

Every Python programmer should peruse that chapter to learn what is available for possible future use.

--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to