0% found this document useful (0 votes)
17 views

Ipython

The document discusses IPython features including commands like ?, %quickref, help, object?, %env, %cd, %colors, %dirs, %doctest_mode, %edit, %gui, %history, %logon, %logoff, %logstart, and %lsmagic. IPython allows interactive Python programming with additional features beyond the standard Python prompt.

Uploaded by

Obulesh A
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Ipython

The document discusses IPython features including commands like ?, %quickref, help, object?, %env, %cd, %colors, %dirs, %doctest_mode, %edit, %gui, %history, %logon, %logoff, %logstart, and %lsmagic. IPython allows interactive Python programming with additional features beyond the standard Python prompt.

Uploaded by

Obulesh A
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

• You don’t need to know anything beyond

Python to start using IPython – just type


commands as you would at the standard
Python prompt.
• But IPython can do much more than the
standard prompt
four most helpful commands

Command Description

? Introduction and overview of IPython’s features.

%quickref Quick reference.

help Python’s own help system.

object? Details about ‘object’, use ‘object??’ for extra details.


• %env : Get, set, or list environment variables.
• Usage:
• %env: lists all environment variables/values
%env var: get value for var %env var val: set
value for var %env var=val: set value for var
%env var=$val: set value for var, using python
expansion if possible
• %cd Change the current working directory.
• This command automatically maintains an internal list of directories you visit
during your IPython session, in the variable _dh. The command %dhist shows
this history nicely formatted. You can also do ‘cd -<tab>’ to see directory history
conveniently.
• Usage:
• cd ‘dir’: changes to directory ‘dir’.
• cd -: changes to the last visited directory.
• cd -<n>: changes to the n-th directory in the directory history.
• cd –foo: change to directory that matches ‘foo’ in history
• cd -b <bookmark_name>: jump to a bookmark set by %bookmark(note: cd
<bookmark_name> is enough if there is nodirectory <bookmark_name>, but a
bookmark with the name exists.) ‘cd -b <tab>’ allows you to tab-complete
bookmark names.
• %colorsSwitch color scheme for prompts, info
system and exception handlers.
• Currently implemented schemes: NoColor,
Linux, LightBG.
• Color scheme names are not case-sensitive.
• Examples
• To get a plain black and white terminal:
• %colors nocolor
• %dirs
• Return the current directory stack.
• %doctest_modeToggle doctest mode on and off.
• This mode is intended to make IPython behave as
much as possible like a plain Python shell, from the
perspective of how its prompts, exceptions and
output look. This makes it easy to copy and paste
parts of a session into doctests. It does so by:
– Changing the prompts to the classic >>> ones.
– Changing the exception reporting mode to ‘Plain’.
– Disabling pretty-printing of output.
• %edit
• Bring up an editor and execute the resulting
code.
• Usage:%edit [options] [args]
• %gui wx
• # enable wx
• %gui qt4|qt
• %gui qt5
• %history
• %history [-n] [-o] [-p] [-t] [-f FILENAME] [-g
[PATTERN [PATTERN ...]]] [-l [LIMIT]] [-u] [range
[range ...]]
• 4
• Line 4, current session
• 4-6 Lines 4-6, current session
• 243/1-5
• Lines 1-5, session 243
• ~2/7Line 7, session 2 before current~
• 8/1-~6/5 From the first line of 8 sessions ago, to the
fifth line of 6 sessions ago.
• Ex: %history -n 4-6
• %logon
• %logoff
• %logstart
• %lsmagic¶
• List currently available magic functions.

• %macro

You might also like