You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I like the idea of exposing Python's command line flags, but I think
this API is a bit odd. I'd rather see it be a struct with members named
after the various arguments and values that are ints or bools -- or
simply a bunch of new flags directly in the sys module if making it a
string is too much work.
It also looks like the patch includes a few unrelated changes to
install.py and site.py.
Can't you use a namedtuple? Then printing it would show the names of
the flags...
... and increase the startup costs of Python by loading several
additional modules. The collections module imports _collections,
operator and keyword. I'd rather see a better repr function for the
sequence types.
On Jan 13, 2008 9:45 AM, Christian Heimes <[email protected]> wrote:
Christian Heimes added the comment:
Guido van Rossum wrote:
> Can't you use a namedtuple? Then printing it would show the names of
> the flags...
... and increase the startup costs of Python by loading several
additional modules. The collections module imports _collections,
operator and keyword. I'd rather see a better repr function for the
sequence types.
Can we make it a function so that it is lazy? That way you can still
use namedtuple but it is only imported when the function is called
instead of during sys' initialization.
Nice -- perhaps you can make it look like a function call,
posix.stat_result(st_mode=..., ...)? (Then someone else might finally
create a constructor with such a signature. :-)
Maybe not, but note that there is both a Py_InteractiveFlag and Py_InspectFlag, and they enable different things (they are both set by -i, while setting the PYTHONINSPECT envvar only activates Py_InspectFlag).
Activity
tiran commentedon Jan 12, 2008
The output should be self explaining:
./python -tt -E -OO -Qnew -c "import sys; print sys.cmd_flags"
('Qnew', 'O', 'OO', 'E', 't', 'tt')
I'll provide doc updates and a mini test if the patch wanted.
gvanrossum commentedon Jan 12, 2008
I like the idea of exposing Python's command line flags, but I think
this API is a bit odd. I'd rather see it be a struct with members named
after the various arguments and values that are ints or bools -- or
simply a bunch of new flags directly in the sys module if making it a
string is too much work.
It also looks like the patch includes a few unrelated changes to
install.py and site.py.
tiran commentedon Jan 13, 2008
The new patch is using a struct sequence (like the result of os.stat):
Please ignore the other files. They are part of my second PEP.
gvanrossum commentedon Jan 13, 2008
Can't you use a namedtuple? Then printing it would show the names of
the flags...
tiran commentedon Jan 13, 2008
Guido van Rossum wrote:
... and increase the startup costs of Python by loading several
additional modules. The collections module imports _collections,
operator and keyword. I'd rather see a better repr function for the
sequence types.
gvanrossum commentedon Jan 13, 2008
Agreed. It's kind of unfortunate that we have two implementations for
the same concept, one in C and one in Python.
brettcannon commentedon Jan 13, 2008
On Jan 13, 2008 9:45 AM, Christian Heimes <[email protected]> wrote:
Can we make it a function so that it is lazy? That way you can still
use namedtuple but it is only imported when the function is called
instead of during sys' initialization.
tiran commentedon Jan 13, 2008
I've coded sys.flags for my per-user site-packages PEP. I could make it
a function but the function would be called by site.py on every startup.
tiran commentedon Jan 13, 2008
Does anybody see a problem with this repr slot implementation for
structseq? It gives this output:
>>> os.stat(".") <posix.stat_result st_mode=16832, st_ino=11666571L, st_dev=65025L, st_nlink=20, st_uid=1000, st_gid=1000, st_size=4096L, st_atime=1200261754, st_mtime=1200261721, st_ctime=1200261721>gvanrossum commentedon Jan 14, 2008
Nice -- perhaps you can make it look like a function call,
posix.stat_result(st_mode=..., ...)? (Then someone else might finally
create a constructor with such a signature. :-)
tiran commentedon Jan 14, 2008
Committed in r59947, r59948 and r59949
merwok commentedon Dec 30, 2010
I’ve recently remarked that -i maps to both sys.flags.inspect and sys.flags.interactive. Is this behavior useful?
birkenfeld commentedon Dec 30, 2010
Maybe not, but note that there is both a Py_InteractiveFlag and Py_InspectFlag, and they enable different things (they are both set by -i, while setting the PYTHONINSPECT envvar only activates Py_InspectFlag).
merwok commentedon Dec 31, 2010
Okay, so having both flags makes sense.