[IPython-user] Passing arguments to run command

Jeremy Conlin jeremit0@gmail....
Mon May 11 13:55:31 CDT 2009


On Mon, May 11, 2009 at 2:38 PM, Gökhan SEVER <gokhansever@gmail.com> wrote:

> I meant in ipython.
>
> It does run actually if an alias be defined for the script. However, in
> this case I can't get variables and /or results in to the ipython's
> namespace.


The only way I'm aware of to run this in iPython is to use the run command.
 This is just a script in the current directory.  A minimal example is:

# ------------------------------------
import sys

if __name__ == "__main__":

    f = sys.argv[1:]
    print f
# ------------------------------------

If you pass multiple files to this as you would in bash f has the
value ['test*.dat'].

Jeremy





>
>
> Gökhan
>
>
>
> On Mon, May 11, 2009 at 1:35 PM, Jeremy Conlin <jeremit0@gmail.com> wrote:
>
>>
>>
>> On Mon, May 11, 2009 at 2:24 PM, Gökhan SEVER <gokhansever@gmail.com>wrote:
>>
>>> Hi,
>>>
>>> This might be might a solution for your case:
>>>
>>> In [1]: files = !ls test*
>>>
>>> In [2]: for i in files:
>>>    ....:     run myScripy.py $i
>>>
>>> However, there could be a simpler solution that I don't know of as well.
>>>
>>> Do you have any idea how to run your script without issuing a "run"
>>> command in front of it?
>>>
>>
>> I can run my command just fine in bash without any problems by replacing
>> "run" with python.
>>
>> Jeremy
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20090511/985d224a/attachment.html 


More information about the IPython-user mailing list