Wrap a function

alex23 wuwei23 at gmail.com
Thu Jan 28 21:38:20 EST 2010


Joan Miller <pelok... at gmail.com> wrote:
> Does anybody knows any library to help me to avoid the use of the main
> quotes, and brackets?
> I would to use anything as:
> $ ls /home => run("ls /home")

It's not a library, but IPython[1] provides a lot of what you're
after:

IPython 0.9.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object'. ?object also works, ?? prints
more.

In [1]: ls /home
bb/  dcallan/  ehornsby/  ftp/	uqamartl/  uqckorte/  uqmtrev2/

In [2]: path = '/home'

In [3]: ls $path
bb/  dcallan/  ehornsby/  ftp/	uqamartl/  uqckorte/  uqmtrev2/

In [4]: output = !ls $path

In [5]: output
Out[5]: SList (.p, .n, .l, .s, .grep(), .fields(), sort() available):
0: bb
1: dcallan
2: ehornsby
3: ftp
4: uqamartl
5: uqckorte
6: uqmtrev2

In [6]: output[6]
Out[6]: 'uqmtrev2'

You'll need to run your scripts with IPython, so this may not be a
solution if you plan on distributing them.

[1] http://ipython.scipy.org/



More information about the Python-list mailing list