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.015 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'paths': 0.05; 'python': 0.09; 'ambiguity': 0.09; 'does,': 0.09; 'subject:command': 0.09; '"python': 0.16; '$0,': 0.16; '24,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'least,': 0.16; 'time).': 0.16; 'wrote:': 0.17; 'exists': 0.17; 'thu,': 0.17; 'jan': 0.18; 'causing': 0.20; 'issue.': 0.20; 'sets': 0.23; 'script': 0.24; 'header:In-Reply-To:1': 0.25; 'message-id:@mail.gmail.com': 0.27; "d'aprano": 0.29; 'equivalent,': 0.29; 'once,': 0.29; 'steven': 0.29; 'probably': 0.29; 'usually': 0.30; 'worked': 0.30; 'relative': 0.30; 'problem.': 0.32; 'file': 0.32; 'to:addr:python- list': 0.33; 'another': 0.33; 'received:google.com': 0.34; 'pm,': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'there': 0.35; 'but': 0.36; 'display': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'fact': 0.38; 'to:addr:python.org': 0.39; 'called': 0.39; 'think': 0.40; 'your': 0.60; 'between': 0.63; 'ever': 0.63; '2013': 0.84; 'hardly': 0.84; 'received:209.85.160.51': 0.84; 'received:mail-pb0-f51.google.com': 0.84; 'burn': 0.91; 'have.': 0.95 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:content-type; bh=/CdJ+7oIe2Bc97ZnV9KxO6VyGbjiJb5rb2XtxrOEbnc=; b=KxYwPZw0bflGLdkWA2KlNvNWrQLDrDZGgq2a6J19c8uSv+hlSR6bV0zahnumhJIC7u J/xvzbRudh1nR+G1KF/THjaH3LKfJcVuMaSU6EkEWnxQQg8aL9bSaHv9okH8j4uplNLc vjfam7m5ZA9k2b7ktmSPWc24cvZQWI834hJzO7uQGjs42p1/+isvFFs5QuNKU+LY1wwl dadvRxyER77kUCbehIru/nif1StRytLn6X0vTq4y2umoSi24+weHhnn7jVXnJ7d9xJa1 Is5j/8z44lf2mVNcphQfKCUX+ePYJsxZmBgscZalDK1D8IxQTYtKO2iRdPZFWuzRz+ie JUtQ== MIME-Version: 1.0 X-Received: by 10.68.253.230 with SMTP id ad6mr1751307pbd.84.1359004005371; Wed, 23 Jan 2013 21:06:45 -0800 (PST) In-Reply-To: <5100bd49$0$29877$c3e8da3$5496439d@news.astraweb.com> 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> Date: Thu, 24 Jan 2013 16:06:45 +1100 Subject: Re: Retrieving the full command line From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1359004008 news.xs4all.nl 6909 [2001:888:2000:d::a6]:41309 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:37538 On Thu, Jan 24, 2013 at 3:49 PM, Steven D'Aprano wrote: > Note however that there is an ambiguity between calling "python -mspam" > and calling a script literally named "-mspam". But that same ambiguity > exists in the shell, so I don't consider it a problem. You cannot call a > script named -mspam unless you use something like this "python ./-mspam". Another spanner for your works: "python -- -mspam" succeeds. That sets argv[0] to '-mspam'. > People hardly ever care about argv[0]. At least, I don't think I ever > have. But the OP does, and Python mangling argv[0] is causing him grief > because it lies, claiming to have called the __main__.py of his package > directly when in fact he called it with -m. Usually when I reference argv[0], $0, or any equivalent, it's for a usage display - eg: USAGE: $0 [opts] infile [outfile] --foo Fooify the file --bar Burn your computer to the ground So I don't particularly care about symlinks or relative paths (if it worked once, it'll probably work another time). But ambiguities may be an issue. ChrisA