Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nntp-feed.chiark.greenend.org.uk!ewrotcd!news.nosignal.org!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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; "'python": 0.07; 'python': 0.09; 'cherrypy': 0.09; 'fetch': 0.09; 'imported': 0.09; 'spec': 0.09; 'subclass': 0.09; 'subject:command': 0.09; 'cc:addr:python- list': 0.10; 'slightly': 0.15; '(via': 0.16; 'benjamin': 0.16; 'cc:name:python list': 0.16; 'merely': 0.16; 'somehow.': 0.16; 'wrote:': 0.17; 'tim': 0.18; 'equivalent': 0.20; 'sort': 0.21; 'import': 0.21; 'os,': 0.22; 'skip:_ 20': 0.22; 'cc:2**0': 0.23; 'command': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'guess': 0.27; 'message-id:@mail.gmail.com': 0.27; 'inspect': 0.29; 'piece': 0.29; 'restart': 0.29; "i'm": 0.29; 'code': 0.31; 'structure': 0.32; 'loading': 0.33; 'knowledge': 0.33; 'entry': 0.33; 'received:google.com': 0.34; 'whatever': 0.35; 'received:209.85': 0.35; 'really': 0.36; 'but': 0.36; 'why': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'application': 0.40; 'your': 0.60; "you've": 0.61; 'face': 0.61; 'first': 0.61; 'is.': 0.62; 'information': 0.63; 'talking': 0.66; '2013': 0.84; 'me).': 0.84; 'oscar': 0.84; 'seen.': 0.84; 'to:addr:mail': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=ieZgtFXpr+mIgXI2+TZoq18b4qypoOYjbkKPIJ5iCkc=; b=uuT941WRsf+Nh6prBnI4e+asqLW+mq/d1HvSwUwcePSCSTtRlZ3+16Rfk5NfO6wQ3W sed2+R/MOt9x0wciZ6hKxRHPaFIk8DBwko7kEjbXm3CqybECXUktpt6V2NKYal3QSTAh D6Qf0HAUjsDVHXuKi1MLiSHIZrrdeivWvA1YJGQGBYevOLF2HeKcgPH7hG1bf8UcNxh4 YBrT5NJSaqOWg6mqTCdgvn0hKYQ9QJRMi1NOV4lD4K1g+pNa0gwIQ4kSCDaDKrskOkJF whCKylyJrd+eIzqv21EWzKXpXbAodaVf99qppYeRNif3qriX89/lhIxAuLvCdo2XUtXP q81A== MIME-Version: 1.0 X-Received: by 10.152.131.137 with SMTP id om9mr2246667lab.18.1359041311967; Thu, 24 Jan 2013 07:28:31 -0800 (PST) In-Reply-To: <51013B0C.6000309@timgolden.me.uk> References: <50FE5AC7.3050909@timgolden.me.uk> <50ff24e8$0$29994$c3e8da3$5496439d@news.astraweb.com> <50ff5ffc$0$29877$c3e8da3$5496439d@news.astraweb.com> <5100bd49$0$29877$c3e8da3$5496439d@news.astraweb.com> <51011340.6020309@timgolden.me.uk> <51013B0C.6000309@timgolden.me.uk> Date: Thu, 24 Jan 2013 15:28:31 +0000 Subject: Re: Retrieving the full command line From: Oscar Benjamin To: Tim Golden Content-Type: text/plain; charset=ISO-8859-1 Cc: Python List 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: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1359041321 news.xs4all.nl 6983 [2001:888:2000:d::a6]:41981 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:37599 On 24 January 2013 13:45, Tim Golden wrote: > On 24/01/2013 11:30, Oscar Benjamin wrote: >> I don't really understand what your spec is. Why do you need to >> inspect this information from sys.argv? Can you not just always use >> 'python -m pkg' as your entry point? > [SNIP] > > For completeness, I'm talking about the cherrypy Autoreloader which > attempts to restart (via execv) whatever process was responsible for > loading it in the first place, via an identical or equivalent command > line. The current (cherrypy) code simply joins sys.executable and > sys.argv but this fails in the face of python -m as we have seen. > > The cherrypy package has no especial knowledge of the structure of the > application which imported it and so must piece together the command > line somehow. Clearly, I can take various approaches of the sort > which you've outlined, or subclass the reloader, or fetch the original > command line from the OS, etc. It's not that this is a showstopper, > merely slightly surprising. (To me). Ok I understand. Then I guess you want: import __main__ pkg = __main__.__package__ Oscar