optparse with numpy.array?

Steve Holden steve at holdenweb.com
Tue Jan 27 12:37:02 EST 2009


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.
> 
The bottom line is that there is no "natural" way to pass Python objects
through the command line, so you will need to find a natural way to
represent the objects as character strings, and then extend the optparse
module to recognize that type.

regards
 Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC              http://www.holdenweb.com/




More information about the Python-list mailing list