##// END OF EJS Templates
Python vs IPython: recommend %cd, %env over !cd, !export (#14629)...
M Bussonnier -
r29044:cb55d942 merge main
parent child Browse files
Show More
@@ -152,13 +152,7 This allows to execute simple commands when present in beginning of the line:
152 In[1]: !pwd
152 In[1]: !pwd
153 /User/home/
153 /User/home/
154
154
155 Change directory:
155 Edit file:
156
157 .. code-block:: ipython
158
159 In[1]: !cd /var/etc
160
161 Or edit file:
162
156
163 .. code-block:: ipython
157 .. code-block:: ipython
164
158
@@ -198,6 +192,10 You can combine the different possibilities in for loops, conditions, functions.
198 !cp $file {file.split('.')[0] + '.bak'}
192 !cp $file {file.split('.')[0] + '.bak'}
199
193
200
194
195 Each ``!`` gets executed in a separate shell, so changing directory by ``!cd`` or env vars ``!export FOO=bar`` will have no effect.
196 Use instead the built-in magics ``%cd DIR/`` (there are also ``%pushd DIR/``, ``%dirs``, ``%popd``) and ``%env FOO=bar``.
197
198
201 Magics
199 Magics
202 ------
200 ------
203
201
General Comments 0
You need to be logged in to leave comments. Login now