[IPython-user] Re: Changing context in iPython CLI
DogWalker
forestiero at qwest.net
Thu Oct 6 14:22:47 CDT 2005
"Chris Youb" <nfn_nln at hotmail.com> said:
>I use the iPython shell as a command-line interface for one of my programs.
>Unfortunately, I repeatedly have to prefix my commands with the variable name
>I've setup. Is there any way to change/imply context in iPython. Here is an
>example of what I mean using an instance of a String for simplicity:
>
>This is what I do now:
>
>In [2]: x.lower()
>Out[2]: 'this is a string!'
>
>In [3]: x.swapcase()
>Out[3]: 'tHIS IS A sTRING!'
>
>When I'd really just like to type this:
>
>In [2]: lower()
>Out[2]: 'this is a string!'
>
>In [3]: swapcase()
>Out[3]: 'tHIS IS A sTRING!'
>
Define a function to return what you want:
def lower():return x.lower()
More information about the IPython-user
mailing list