##// END OF EJS Templates
- Manual updates...
fperez -
Show More
@@ -1,7 +1,7 b''
1 1 # -*- coding: utf-8 -*-
2 2 """Magic functions for InteractiveShell.
3 3
4 $Id: Magic.py 1029 2006-01-18 07:33:38Z fperez $"""
4 $Id: Magic.py 1030 2006-01-18 19:24:48Z fperez $"""
5 5
6 6 #*****************************************************************************
7 7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
@@ -1935,18 +1935,16 b' Currently the magic system has the following functions:\\n"""'
1935 1935 print
1936 1936 else:
1937 1937 print 'done. Executing edited code...'
1938 try:
1939 1938 self.shell.safe_execfile(filename,self.shell.user_ns)
1939 if use_temp:
1940 try:
1941 return open(filename).read()
1940 1942 except IOError,msg:
1941 1943 if msg.filename == filename:
1942 1944 warn('File not found. Did you forget to save?')
1943 1945 return
1944 1946 else:
1945 1947 self.shell.showtraceback()
1946 except:
1947 self.shell.showtraceback()
1948 if use_temp:
1949 return open(filename).read()
1950 1948
1951 1949 def magic_xmode(self,parameter_s = ''):
1952 1950 """Switch modes for the exception handlers.
@@ -1,3 +1,8 b''
1 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu>
2
3 * IPython/Magic.py (magic_edit): fix check for when users don't
4 save their output files, the try/except was in the wrong section.
5
1 6 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
2 7
3 8 * IPython/Magic.py (magic_run): fix __file__ global missing from
@@ -2474,6 +2474,121 b' all'
2474 2474 %save
2475 2475 \family default
2476 2476 allows you to select which lines of input you need to save.
2477 \layout Subsubsection*
2478
2479 Lightweight 'version control'
2480 \layout Standard
2481
2482 When you call
2483 \family typewriter
2484 %edit
2485 \family default
2486 with no arguments, IPython opens an empty editor with a temporary file,
2487 and it returns the contents of your editing session as a string variable.
2488 Thanks to IPython's output caching mechanism, this is automatically stored:
2489 \layout LyX-Code
2490
2491 In [1]: %edit
2492 \layout LyX-Code
2493
2494 IPython will make a temporary file named: /tmp/ipython_edit_yR-HCN.py
2495 \layout LyX-Code
2496
2497 Editing...
2498 done.
2499 Executing edited code...
2500 \layout LyX-Code
2501
2502 hello - this is a temporary file
2503 \layout LyX-Code
2504
2505 Out[1]: "print 'hello - this is a temporary file'
2506 \backslash
2507 n"
2508 \layout Standard
2509
2510 Now, if you call
2511 \family typewriter
2512 `%edit -p'
2513 \family default
2514 , IPython tries to open an editor with the same data as the last time you
2515 used
2516 \family typewriter
2517 %edit
2518 \family default
2519 .
2520 So if you haven't used
2521 \family typewriter
2522 %edit
2523 \family default
2524 in the meantime, this same contents will reopen; however, it will be done
2525 in a
2526 \emph on
2527 new file
2528 \emph default
2529 .
2530 This means that if you make changes and you later want to find an old version,
2531 you can always retrieve it by using its output number, via
2532 \family typewriter
2533 `%edit _NN'
2534 \family default
2535 , where
2536 \family typewriter
2537 NN
2538 \family default
2539 is the number of the output prompt.
2540 \layout Standard
2541
2542 Continuing with the example above, this should illustrate this idea:
2543 \layout LyX-Code
2544
2545 In [2]: edit -p
2546 \layout LyX-Code
2547
2548 IPython will make a temporary file named: /tmp/ipython_edit_nA09Qk.py
2549 \layout LyX-Code
2550
2551 Editing...
2552 done.
2553 Executing edited code...
2554 \layout LyX-Code
2555
2556 hello - now I made some changes
2557 \layout LyX-Code
2558
2559 Out[2]: "print 'hello - now I made some changes'
2560 \backslash
2561 n"
2562 \layout LyX-Code
2563
2564 In [3]: edit _1
2565 \layout LyX-Code
2566
2567 IPython will make a temporary file named: /tmp/ipython_edit_gy6-zD.py
2568 \layout LyX-Code
2569
2570 Editing...
2571 done.
2572 Executing edited code...
2573 \layout LyX-Code
2574
2575 hello - this is a temporary file
2576 \layout LyX-Code
2577
2578 IPython version control at work :)
2579 \layout LyX-Code
2580
2581 Out[3]: "print 'hello - this is a temporary file'
2582 \backslash
2583 nprint 'IPython version control at work :)'
2584 \backslash
2585 n"
2586 \layout Standard
2587
2588 This section was written after a contribution by Alexander Belchenko on
2589 the IPython user list.
2590 \layout LyX-Code
2591
2477 2592 \layout Subsection
2478 2593
2479 2594 Effective logging
General Comments 0
You need to be logged in to leave comments. Login now