I understand ! tells iPython to treat the expression as "Bashy", but how do I tell iPython to treat an expression as "Pythony" so I can mix the two together?
For example, if I have a list of folders, how do I cd into them by indexing into the list?
In [57]: x = !find . -type d
In [58]: !cd x[-1]
sh: line 0: cd: x[-1]: No such file or directory
iPython is not making the substitution for x[-1]
asked Jan 13, 2014 at 3:24
jaynp
3,3354 gold badges35 silver badges45 bronze badges
1 Answer 1
!cd {x[-1]}
If you want change current dir of ipython:
cd {x[-1]}
answered Jan 13, 2014 at 3:33
clyfish
10.5k2 gold badges33 silver badges23 bronze badges
default