Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #37388

Re: Retrieving the full command line

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <oscar.j.benjamin@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'interpreter': 0.04; 'modify': 0.05; 'python': 0.09; 'path.': 0.09; 'subject:command': 0.09; 'cc:addr:python-list': 0.10; 'bug,': 0.16; 'cc:name:python list': 0.16; 'rewritten': 0.16; 'sys.path': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'wanted)': 0.16; 'wrote:': 0.17; 'previously': 0.18; 'app': 0.19; 'equivalent': 0.20; 'proposed': 0.20; 'bit': 0.21; 'import': 0.21; 'explicit': 0.22; 'option.': 0.22; 'cc:2**0': 0.23; 'idea': 0.24; 'command': 0.24; 'script': 0.24; 'least': 0.25; 'cc:addr:python.org': 0.25; 'header :In-Reply-To:1': 0.25; 'separate': 0.27; 'message- id:@mail.gmail.com': 0.27; 'run': 0.28; "d'aprano": 0.29; 'steven': 0.29; 'function': 0.30; 'located': 0.31; 'point': 0.31; '(and': 0.32; 'file': 0.32; 'launch': 0.32; "skip:' 20": 0.32; 'received:google.com': 0.34; 'path': 0.35; 'similar': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'but': 0.36; "didn't": 0.36; 'useful': 0.36; 'option': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'instead': 0.39; 'different': 0.63; 'more': 0.63; 'making': 0.64; 'believe': 0.69; '2013': 0.84; 'distinguish': 0.84; 'disturbed': 0.84; 'oscar': 0.84
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=UOHNfYPqp53Qd4/GbXhXwS7bgUGv8zqWhkdZ7HbhY44=; b=R9BtQRUvGhAnJj5HoBEkZ9qIjbNGzHkj3/yrgx3RowZp0zeaF12Eh5G+lK6f3YJpTo 1Y89gGSywFeenlv9fYw7pk4paG1pffamY8zN9vdZVAlhzuj0PRV2zqarp2n0S4ikaFoF 9bRPO40aIbEvRG3fpnbqxmxhuN5R1Mfy5Plrk0Fawpk7Uthbo3QQHZVWlLl87cJNtQE2 4akGKkNV3jVKgifbyCuKKK0RfWRMWBfIWf6IxzM+jo4YjiLdsAzdnFunp6wolKV4k50i wMM5sBQIupBErdBKVy8VCtj/mZ9UzsRiZozDg9bw4Q3HhlnDlHU2ScrCrY2AgnhcySw2 SFow==
MIME-Version 1.0
X-Received by 10.152.144.71 with SMTP id sk7mr23152659lab.29.1358902401311; Tue, 22 Jan 2013 16:53:21 -0800 (PST)
In-Reply-To <50ff24e8$0$29994$c3e8da3$5496439d@news.astraweb.com>
References <50FE5AC7.3050909@timgolden.me.uk> <kdm962$cc3$1@ger.gmane.org> <mailman.793.1358867242.2939.python-list@python.org> <50ff24e8$0$29994$c3e8da3$5496439d@news.astraweb.com>
Date Wed, 23 Jan 2013 00:53:21 +0000
Subject Re: Retrieving the full command line
From Oscar Benjamin <oscar.j.benjamin@gmail.com>
To "Steven D'Aprano" <steve+comp.lang.python@pearwood.info>
Content-Type text/plain; charset=ISO-8859-1
Cc Python List <python-list@python.org>
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.851.1358902404.2939.python-list@python.org> (permalink)
Lines 34
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1358902404 news.xs4all.nl 6841 [2001:888:2000:d::a6]:35047
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:37388

Show key headers only | View raw


On 22 January 2013 23:46, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
[SNIP]
>
> I am a bit disturbed that you cannot distinguish between:
>
> python C:\something\on\pythonpath\app\__main__.py
>
> python -m app
>
>
> by inspecting the command line. I consider it a bug, or at least a
> misfeature, if Python transforms the command line before making it
> available in sys.argv.

The purpose of the -m option is that you can run a script that is
located via the Python import path instead of an explicit file path.
The idea is that if '/path/to/somewhere' is in sys.path then:
    python -m script arg1 arg2
is equivalent to
    python /path/to/somewhere/script.py arg1 arg2

If Python didn't modify sys.argv then 'script.py' would need to be
rewritten to understand that sys.argv would be in a different format
when it was invoked using the -m option.

I believe that it has previously been proposed to include something
like sys.raw_argv, although perhaps for different reasons. Although
something that might be more useful to the OP (and that I at one point
wanted) would be a function similar to execfile but that would launch
a separate process using the same interpreter as the current process.


Oscar

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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