Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #37279
| 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 | <mail@timgolden.me.uk> |
| 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; 'skip:[ 20': 0.03; 'executed': 0.07; 'filenames': 0.07; 'rewrite': 0.07; 'used.': 0.07; 'python': 0.09; 'cherrypy': 0.09; 'imports': 0.09; 'itself,': 0.09; 'rebuild': 0.09; 'subject:command': 0.09; 'terry': 0.09; 'cc:addr:python-list': 0.10; '"python': 0.16; 'determining': 0.16; 'from:addr:timgolden.me.uk': 0.16; 'from:name:tim golden': 0.16; 'identifiers': 0.16; 'message- id:@timgolden.me.uk': 0.16; 'obviously,': 0.16; 'received:74.55.86': 0.16; 'received:74.55.86.74': 0.16; 'received:smtp.webfaction.com': 0.16; 'received:webfaction.com': 0.16; 'reedy': 0.16; 'sense,': 0.16; 'tjg': 0.16; 'wrote:': 0.17; 'issue,': 0.17; 'tim': 0.18; 'module': 0.19; 'code.': 0.20; 'translate': 0.20; 'meant': 0.21; 'combination': 0.22; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'command': 0.24; 'cc:addr:python.org': 0.25; '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; '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; 'received:192.168.100': 0.33; 'updated': 0.34; 'clear': 0.35; 'similar': 0.35; 'there': 0.35; 'but': 0.36; 'development.': 0.36; 'should': 0.36; 'skip:p 20': 0.36; 'does': 0.37; 'uses': 0.37; 'subject:: ': 0.38; 'received:192': 0.39; 'received:192.168': 0.40; 'within': 0.64; 'combining': 0.71; 'from:addr:mail': 0.71; 'programs,': 0.71; 'directly.': 0.78; 'internally.': 0.84; 'canonical': 0.91; 'to:none': 0.93 |
| Date | Tue, 22 Jan 2013 15:07:18 +0000 |
| From | Tim Golden <mail@timgolden.me.uk> |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20120907 Thunderbird/15.0.1 |
| MIME-Version | 1.0 |
| CC | python-list@python.org |
| Subject | Re: Retrieving the full command line |
| References | <50FE5AC7.3050909@timgolden.me.uk> <kdm962$cc3$1@ger.gmane.org> |
| In-Reply-To | <kdm962$cc3$1@ger.gmane.org> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | 7bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.793.1358867242.2939.python-list@python.org> (permalink) |
| Lines | 34 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1358867242 news.xs4all.nl 6946 [2001:888:2000:d::a6]:33032 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:37279 |
Show key headers only | View raw
On 22/01/2013 14:53, Terry Reedy wrote: > 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. To be clear: it's Python itself, not the reloader, which is coming up with __main__.py. sys.executable is "c:\python33\python.exe" and sys.argv is ['c:\path\to\__main__.py'] for a program which has been started by "c:\python33\python.exe -mpath\to". Obviously, there is any number of ways around this specific issue, including what you suggest: a canonical rewrite of "python path\to\__main__.py" into "python -mpath\to". But it's not clear to me that this rewrite should be the responsibility of calling code. TJG
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: Retrieving the full command line Tim Golden <mail@timgolden.me.uk> - 2013-01-22 15:07 +0000
Re: Retrieving the full command line Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-01-22 23:46 +0000
Re: Retrieving the full command line Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-01-23 00:53 +0000
Re: Retrieving the full command line Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-01-23 03:58 +0000
Re: Retrieving the full command line Tim Golden <mail@timgolden.me.uk> - 2013-01-23 09:58 +0000
Re: Retrieving the full command line Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-01-23 10:01 +0000
Re: Retrieving the full command line Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-01-24 04:49 +0000
Re: Retrieving the full command line Chris Angelico <rosuav@gmail.com> - 2013-01-24 16:06 +1100
Re: Retrieving the full command line Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-01-24 10:06 +0000
Re: Retrieving the full command line Tim Golden <mail@timgolden.me.uk> - 2013-01-24 10:56 +0000
Re: Retrieving the full command line Tim Golden <mail@timgolden.me.uk> - 2013-01-24 11:04 +0000
Re: Retrieving the full command line Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-01-24 11:30 +0000
Re: Retrieving the full command line Tim Golden <mail@timgolden.me.uk> - 2013-01-24 13:45 +0000
Re: Retrieving the full command line Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-01-24 15:28 +0000
Re: Retrieving the full command line Tim Golden <mail@timgolden.me.uk> - 2013-01-24 15:51 +0000
Re: Retrieving the full command line Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-01-24 16:08 +0000
Re: Retrieving the full command line Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-01-24 16:53 +0000
Re: Retrieving the full command line Tim Golden <mail@timgolden.me.uk> - 2013-01-24 17:13 +0000
Re: Retrieving the full command line Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-01-24 20:01 +0000
Re: Retrieving the full command line Tim Golden <mail@timgolden.me.uk> - 2013-01-24 20:54 +0000
csiph-web