optparse with numpy.array?

Robert Kern robert.kern at gmail.com
Tue Jan 27 16:21:40 EST 2009


On 2009-01-27 03:09, Johan Ekh wrote:
> Thanks,
> James I will try your suggestion!
> Robert, what mean with "interactively" is that i would like to create an
> array in the ipython shell, e.g. with m_i = array([1.0, 2.0, 3.0]) or
> by reading a file with values etc., and then execute my program with
> "myprog -m m_i" and thus pass the array "m_i" to my program.
>
> This is just an example. I would like to pass several arrays. My program
> will be wrapped inside a loop and the arrays are updated
> in each loop.
>
> I have never heard of the "argparse" library. Do you think that it would
> be better to use that in my case?

No. Basically, no command line parser is going to work like you want. If you 
want to run something from IPython using the objects in your IPython session, 
you should make a module instead of a program. Import your module, and call its 
functions. Then you can pass whatever objects you like.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco




More information about the Python-list mailing list