[IPython-dev] Expanding $a to 'f1 f2' when $a is ['f1','f2']
Ville Vainio
vivainio at kolumbus.fi
Thu Mar 17 10:07:27 EST 2005
On Wed, 2005-03-16 at 15:18 -0700, Fernando Perez wrote:
> Sorry, but the amount of special-casing that this would require is almost
> guaranteed to break somewhere. Keep in mind that you can evaluate arbitrary
> code in $ expressions, so you can do:
>
> rm ${' '.join(junk)}
>
> Not the cleanest, but it works.
>
> The problem is that I simply don't see a way to generically distinguish when
> $foo should be evaluated as a list joined on whitespace and when it should be
> treated as a list. The $ evaluation mechanism is actually a full-blown
> generic interpolation module, Ka-Ping Yee's Itpl, from PEP-215:
>
> http://www.python.org/peps/pep-0215.html
>
> How do you propose such a mechanism do what you want in a generic, safe way?
1. If it's just $junk (i.e. not ${junk})
2. not isinstance(junk, basestring)
3. iter(junk) does not raise TypeError
-> Expand it as " ".join(junk)
More information about the IPython-dev
mailing list