Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #12796
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: One line command line filter |
| Date | 2011-09-05 19:02 -0400 |
| References | <4725b2c3-d930-4fb0-9fe7-a286d150f9c5@d18g2000yqm.googlegroups.com> <mailman.781.1315255602.27778.python-list@python.org> <39f1dbdb-9e25-43b8-b293-395ccfc76e50@p10g2000yqi.googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.784.1315263791.27778.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
One line command line filter Jon Redgrave <jredgrave@capisco.com> - 2011-09-05 13:38 -0700
Re: One line command line filter Thomas Jollans <t@jollybox.de> - 2011-09-05 22:47 +0200
Re: One line command line filter Jon Redgrave <jredgrave@capisco.com> - 2011-09-05 14:32 -0700
Re: One line command line filter Terry Reedy <tjreedy@udel.edu> - 2011-09-05 19:02 -0400
Re: One line command line filter Terry Reedy <tjreedy@udel.edu> - 2011-09-05 18:21 -0400
Re: One line command line filter Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-09-06 09:18 +1000
Re: One line command line filter Terry Reedy <tjreedy@udel.edu> - 2011-09-05 21:25 -0400
Re: One line command line filter Hans Mulder <hansmu@xs4all.nl> - 2011-09-06 13:15 +0200
Re: One line command line filter Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-09-06 09:29 +1000
Re: One line command line filter John Wiegley <jwiegley@gmail.com> - 2011-09-06 01:51 -0500
Re: One line command line filter Peter Otten <__peter__@web.de> - 2011-09-06 09:53 +0200
csiph-web