[IPython-user] Feedback request on a new feature

Fernando Perez fperez at colorado.edu
Mon Dec 22 00:22:20 CST 2003

Hi all,

I'd like to solicit a bit of feedback from the community on a new feature.  I 
often get asked about a quick way to capture shell output to a python variable 
for further manipulation.  Granted, you can always do

In [7]: import commands

In [8]: a=commands.getoutput('ls C*.py')

In [9]: print a

But since ipython is after all a shell which tries to let you do a lot with 
very little typing, having a builtin shortcut for this doesn't sound like an 
unreasonable request to me.  So as a test I coded up the ability to do the 

In [10]: $b=ls C*.py
--- IPython variable set --- b:

the proposed syntax is:

$var_name=shell command

I'd like some feedback on whether people like the idea, both in principle and 
in its current (very much a prototype) implementation.  Some possible 
viewpoints I could see people making, but for which I'd like to know whether 
anyone would _actually_ make them:

- It's bloat:  anyone who needs it enough can easily code it.

- It's not bloat, but a different syntax would be better, like

!!b=ls *py

This subsumes it into the already existing shell syntax without introducing 
yet another special character.  At the rate things are going, ipython is 
making python look like perl!

- I like it, just leave out the stupid comment, people know what they did. 
Just print the output like a shell would.

- Don't even print the output, it should just behave like getoutput().  People 
can print out the variable if they need it (esp. useful if the output is 
potentially huge, but you want it trapped for processing).

- You should split the output and return a list, since that's what people will 
want most of the time.

- ... more?

Anyway, as you can see, I think it may be useful to many, but I'm a bit 
concerned about ugliness and implementation specifics.  Since it's something 
people have asked for, I'd like some feedback.

I've put the code into CVS so you can play with it and tell me what you think. 
  I can later just back it off if there's consensus that it was just a stupid 

I'd also like to know of anything else you may consider necessary for the next 
release.  At this point I have pretty much everything ready and I'd like to 
move forward with releasing the code relatively soon.  The only things 
currently remaining in my mind are:

1. A gettext() related bug which was reported on the tracker.  I'm still 
trying to clarify if that one is really all that different in ipython from 
normal python.

2. Documenting a bit in the manual Gary Bishop's contributions for Windows users.

3. ???

Let me know of anything you think is important, because after this release 
I'll probably start, with Jeff Collin's help, tearing ipython apart for a big 
internal cleanup.  This will mean no more development (except for critical 
bugfixes) done to the current branch.

Thanks, and to all of you who celebrate, Happy Holidays!



More information about the IPython-user mailing list