Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing parameter (directory) to %cd command in ipython notebook

I'm trying to pass a parameter (directory) to a %cd command in ipython notebook as below:

 rootdir = "D:\mydoc"
 %cd rootdir

but i get the following error:

 [Error 2] The system cannot find the file specified: u'rootdir'
 D:\mydoc

when i'm doing

 %cd D:\mydoc

This obviously works but i want to be able to specify my working directories using parameters...

Many thanks who can help me.

Best Wishes

like image 691
tezzaaa Avatar asked Oct 13 '16 09:10

tezzaaa


Video Answer


1 Answers

You can use $ to use the value in a variable.

%cd $rootdir
like image 101
ham Avatar answered Oct 19 '22 21:10

ham