[IPython-dev] Argument parsing (was: Qt api selection re. ipython and matplotlib)

Julian Taylor jtaylor.debian at googlemail.com
Thu Jul 7 12:47:39 EDT 2011


On 07/07/2011 04:00 PM, Darren Dale wrote:
> On Wed, Jul 6, 2011 at 2:19 AM, Brian Granger <ellisonbg at gmail.com> wrote:
>> On Tue, Jul 5, 2011 at 11:06 PM, MinRK <benjaminrk at gmail.com> wrote:
>>> On Jul 5, 2011, at 18:32, Darren Dale <dsdale24 at gmail.com> wrote:
>>>> By the way, I find the new ipython's new argument parsing really
>>>> non-intuitive. It took me 5 attempts to figure out how to do "ipython
>>>> gui=qt", even after skimming the output of "ipython -h". What's wrong
>>>> with "ipython --gui=qt"? Does ipython really need to put its own
>>>> unique spin on argument parsing?
>>>
>>> The reason for Brian's design here is that now the command line args
>>> are coupled with the config system.  Specifying a value on the command
>>> line is now identical to specifying it in a config file, so it looks
>>> like a Python assignment (because it is).  It also means that 100% of
>>> IPython is configurable from the command-line.
>>
>> As Min mentions, the config system syntax *is* Python and we wanted to
>> use a syntax that reflected that.  When you do:
>>
>> Foo.bar=10
>>
>> At the command line, we parse that as Python code and run it through
>> the traits machinery.  Making this:
>>
>> --Foo.bar=10
>>
>> Only obscures the fact that it is parsed as Python.
> 
> That's a bit hyperbolic. I could then argue that "ipython profile
> create" only makes it confusing to figure out what arguments should be
> treated as options and what arguments should be treated as files.
> 
>> This approach
>> also allows us to do things like the following at the command line:
>>
>> Foo.bar=[0,1,2]
>>
>> or even:
>>
>> Foo.bar=range(3)
>>
>> Which is then validated by traits as a list of ints.  We do realize
>> that there is going to be an adjustment period for users and we do
>> need to continue to improve documentation to point out these important
>> changes.
> 
> Could you please include some documentation on how I can invoke
> ipython to run a script without a .py or .ipy extension? Lets say I
> have a python script called "profile", this doesn't work:
> 
> ipython profile
> 
> Or, suppose I have a file named something pathological like foo=bar?
> Python will run it without any problems. Even if I rename it
> foo=bar.py, ipython appears to interpret it as an option, not a
> filename.
> 
> Darren


0.11rc1 breaks some scripts using sys.argv:
$ cat /tmp/tmp.py
import sys
print sys.argv

$ python /tmp/tmp.py
['/tmp/tmp.py']
$ ipython0.10 /tmp/tmp.py
['/tmp/tmp.py']
$ ipython0.11 /tmp/tmp.py
['/home/jtaylor/chroots/python/bin/ipython', '/tmp/tmp.py']

also the -c and -i flag do not work any more. I assume there is some
replacement somewhere but having to dig through pages and pages of docs
just to find commonly used interpreter flags quite annoying.

Best Regards,
Julian Taylor

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20110707/41da7dc1/attachment.sig>


More information about the IPython-dev mailing list