Re: Retrieving the full command line

2013-01-24 Thread Tim Golden
On 24/01/2013 20:01, Oscar Benjamin wrote: On 24 January 2013 17:13, Tim Golden wrote: A package-based module run via -m (python -m package.module) works as described (including the implicit __main__ module, my primary use-case). Does it work in the "python -m package.module" case? It looks t

Re: Retrieving the full command line

2013-01-24 Thread Oscar Benjamin
On 24 January 2013 17:13, Tim Golden wrote: > On 24/01/2013 16:53, Oscar Benjamin wrote: >>> Does it work if you use the -m option to run a module rather than a script? >> >> Sorry that was written incorrectly. I meant to say: does it work when >> a module is directly on sys.path rather than as a

Re: Retrieving the full command line

2013-01-24 Thread Tim Golden
On 24/01/2013 16:53, Oscar Benjamin wrote: >> Does it work if you use the -m option to run a module rather than a script? > > Sorry that was written incorrectly. I meant to say: does it work when > a module is directly on sys.path rather than as a submodule of a > package? In this case __package__

Re: Retrieving the full command line

2013-01-24 Thread Oscar Benjamin
On 24 January 2013 16:08, Oscar Benjamin wrote: > On 24 January 2013 15:51, Tim Golden wrote: >> On 24/01/2013 15:28, Oscar Benjamin wrote: >>> 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 yo

Re: Retrieving the full command line

2013-01-24 Thread Oscar Benjamin
On 24 January 2013 15:51, Tim Golden wrote: > On 24/01/2013 15:28, Oscar Benjamin wrote: >> 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?

Re: Retrieving the full command line

2013-01-24 Thread Tim Golden
On 24/01/2013 15:28, Oscar Benjamin wrote: > 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

Re: Retrieving the full command line

2013-01-24 Thread Oscar Benjamin
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,

Re: Retrieving the full command line

2013-01-24 Thread Tim Golden
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? Sorry about the confusion. I think my original point was simply one of surprise

Re: Retrieving the full command line

2013-01-24 Thread Oscar Benjamin
On 24 January 2013 10:56, Tim Golden wrote: > On 24/01/2013 10:06, Oscar Benjamin wrote: >> On 24 January 2013 04:49, Steven D'Aprano >> wrote: >> [SNIP] >>> >>> Contrariwise, I don't believe that there is currently *any* way to >>> distinguish between running a script with or without -m. That sh

Re: Retrieving the full command line

2013-01-24 Thread Tim Golden
On 24/01/2013 10:56, Tim Golden wrote: > if the package which is reconstructing the command line the package > which was the target of the original command line. Sorry: if the package which is reconstructing the command line *is not* the package which was the target of the original command l

Re: Retrieving the full command line

2013-01-24 Thread Tim Golden
On 24/01/2013 10:06, Oscar Benjamin wrote: > On 24 January 2013 04:49, Steven D'Aprano > wrote: > [SNIP] >> >> Contrariwise, I don't believe that there is currently *any* way to >> distinguish between running a script with or without -m. That should be >> fixed. > > As I said earlier in the threa

Re: Retrieving the full command line

2013-01-24 Thread Oscar Benjamin
On 24 January 2013 04:49, Steven D'Aprano wrote: [SNIP] > > Contrariwise, I don't believe that there is currently *any* way to > distinguish between running a script with or without -m. That should be > fixed. As I said earlier in the thread, the __package__ module global distinguishes the two ca

Re: Retrieving the full command line

2013-01-23 Thread Chris Angelico
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 -mspa

Re: Retrieving the full command line

2013-01-23 Thread Steven D'Aprano
On Wed, 23 Jan 2013 10:01:24 +, Oscar Benjamin wrote: > On 23 January 2013 03:58, Steven D'Aprano > wrote: >> On Wed, 23 Jan 2013 00:53:21 +, Oscar Benjamin wrote: >> >>> On 22 January 2013 23:46, Steven D'Aprano >>> wrote: [SNIP] >>> The purpose of the -m option is that you can run

Re: Retrieving the full command line

2013-01-23 Thread Oscar Benjamin
On 23 January 2013 03:58, Steven D'Aprano wrote: > On Wed, 23 Jan 2013 00:53:21 +, Oscar Benjamin wrote: > >> On 22 January 2013 23:46, Steven D'Aprano >> wrote: [SNIP] >>> >> The purpose of the -m option is that you can run a script that is >> located via the Python import path instead of an

Re: Retrieving the full command line

2013-01-23 Thread Tim Golden
On 23/01/2013 03:58, Steven D'Aprano wrote: > Currently, if I have a package __main__.py that prints sys.argv, I get > results like this: > > steve@runes:~$ python3.3 /home/steve/python/testpackage/__main__.py ham > spam eggs > ['/home/steve/python/testpackage/__main__.py', 'ham', 'spam', 'eggs'

Re: Retrieving the full command line

2013-01-22 Thread Steven D'Aprano
On Wed, 23 Jan 2013 00:53:21 +, Oscar Benjamin wrote: > On 22 January 2013 23:46, Steven D'Aprano > 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

Re: Retrieving the full command line

2013-01-22 Thread Oscar Benjamin
On 22 January 2013 09:24, 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

Re: Retrieving the full command line

2013-01-22 Thread Oscar Benjamin
On 22 January 2013 23:46, Steven D'Aprano 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

Re: Retrieving the full command line

2013-01-22 Thread Steven D'Aprano
On Tue, 22 Jan 2013 15:07:18 +, Tim Golden wrote: > 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 h

Re: Retrieving the full command line

2013-01-22 Thread Tim Golden
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 int

Re: Retrieving the full command line

2013-01-22 Thread Terry Reedy
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

Retrieving the full command line

2013-01-22 Thread Tim Golden
[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