Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'received:verizon.net': 0.07; 'terry': 0.07; 'python': 0.08; 'ah,': 0.09; 'builtin': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'programmer': 0.10; '"or': 0.16; 'expression"': 0.16; 'reedy': 0.16; 'subject:command': 0.16; 'wrote:': 0.16; '>>>': 0.18; 'jan': 0.19; 'header:In-Reply-To:1': 0.22; 'pm,': 0.24; 'index': 0.24; 'skip:_ 20': 0.28; 'import': 0.28; 'accessible': 0.29; 'print': 0.29; 'module': 0.30; 'cases': 0.32; 'to:addr:python-list': 0.33; 'header:User-Agent:1': 0.34; 'header:X-Complaints-To:1': 0.35; 'listed': 0.37; 'but': 0.37; 'something': 0.37; 'could': 0.38; 'think': 0.38; 'received:org': 0.38; 'should': 0.38; 'subject:: ': 0.39; 'header:Mime-Version:1': 0.39; 'missing': 0.39; 'to:addr:python.org': 0.39; 'where': 0.40; 'more': 0.60; '"for': 0.67; 'subject:line': 0.73; 'subject:One': 0.77; 'jon': 0.84; 'chapter.': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: One line command line filter Date: Mon, 05 Sep 2011 19:02:04 -0400 References: <4725b2c3-d930-4fb0-9fe7-a286d150f9c5@d18g2000yqm.googlegroups.com> <39f1dbdb-9e25-43b8-b293-395ccfc76e50@p10g2000yqi.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-74-109-121-73.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20110812 Thunderbird/6.0 In-Reply-To: <39f1dbdb-9e25-43b8-b293-395ccfc76e50@p10g2000yqi.googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1315263791 news.xs4all.nl 2476 [2001:888:2000:d::a6]:59728 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:12796 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