Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'executed': 0.07; 'filenames': 0.07; 'used.': 0.07; 'python': 0.09; 'cherrypy': 0.09; 'imports': 0.09; 'rebuild': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:command': 0.09; 'terry': 0.09; 'determining': 0.16; 'identifiers': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'sense,': 0.16; 'wrote:': 0.17; 'jan': 0.18; 'tim': 0.18; 'module': 0.19; 'translate': 0.20; 'meant': 0.21; 'combination': 0.22; 'command': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'appear': 0.26; 'skip:" 20': 0.26; 'am,': 0.27; 'developing': 0.28; 'header:X-Complaints-To:1': 0.28; 'run': 0.28; "i'm": 0.29; "skip:' 10": 0.30; 'relative': 0.30; '(and': 0.32; 'file': 0.32; 'running': 0.32; 'like:': 0.33; 'to:addr:python-list': 0.33; 'updated': 0.34; 'similar': 0.35; 'there': 0.35; 'received:org': 0.36; 'but': 0.36; 'development.': 0.36; 'should': 0.36; 'does': 0.37; 'uses': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'within': 0.64; 'combining': 0.71; 'programs,': 0.71; 'directly.': 0.78; 'internally.': 0.84; 'received:fios.verizon.net': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Retrieving the full command line Date: Tue, 22 Jan 2013 09:53:37 -0500 References: <50FE5AC7.3050909@timgolden.me.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Thunderbird/17.0 In-Reply-To: <50FE5AC7.3050909@timgolden.me.uk> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1358866454 news.xs4all.nl 6898 [2001:888:2000:d::a6]:53748 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:37276 On 1/22/2013 4:24 AM, Tim Golden wrote: > [Python 2.7/3.3 (and hg tip) running on Windows. Not Windows-specific, > though]. > > I use the python -mpackage incantation to run a package which has a > __main__.py module and which uses relative imports internally. > > I'm developing under cherrypy which includes a reloader for development. > The reloader attempts to rebuild the original > command line by combining sys.executable and sys.argv and then does an > execv. > > There does not appear to be any way within Python of determining the > command line I used. The combination of sys.executable and sys.argv in > this case will look like: "c:\python33\python.exe app/__main__.py". But > running this precludes the use of package-relative imports. If I understand right, the reloader should be updated to translate 'x/__main__.py' to '-m x'. Filenames of form'__x__' are reserved, in a sense, like similar identifiers in programs, and '__main__.py' should not be used for a file meant to executed directly. -- Terry Jan Reedy