Coding basic python in IPython Notebook interactive development environment.
import sys
import io
io?
io??
# IPython Quick Refence
%quickref
# Python Refence
help()
Welcome to Python 2.7! This is the online help utility. If this is your first time using Python, you should definitely check out the tutorial on the Internet at http://docs.python.org/2.7/tutorial/. Enter the name of any module, keyword, or topic to get help on writing Python programs and using Python modules. To quit this help utility and return to the interpreter, just type "quit". To get a list of available modules, keywords, or topics, type "modules", "keywords", or "topics". Each module also comes with a one-line summary of what it does; to list the modules whose summaries contain a given word such as "spam", type "modules spam". help> You are now leaving help and returning to the Python interpreter. If you want to ask for help on a particular object directly from the interpreter, you can type "help(object)". Executing "help('string')" has the same effect as typing a particular string at the help> prompt.
%pdoc io.FileIO
%pdef io.OpenWrapper
No definition header found for io.OpenWrapper
%psource io
%pfile io
# Browse an object with tab
sys
<module 'sys' (built-in)>
# Shift-tab to get more information about a method
open()
# Listing all magic
%lsmagic
Available line magics: %alias %alias_magic %autocall %automagic %autosave %bookmark %cat %cd %clear %colors %config %connect_info %cp %debug %dhist %dirs %doctest_mode %ed %edit %env %gui %hist %history %install_default_config %install_ext %install_profiles %killbgscripts %ldir %less %lf %lk %ll %load %load_ext %loadpy %logoff %logon %logstart %logstate %logstop %ls %lsmagic %lx %macro %magic %man %matplotlib %mkdir %more %mv %notebook %page %pastebin %pdb %pdef %pdoc %pfile %pinfo %pinfo2 %popd %pprint %precision %profile %prun %psearch %psource %pushd %pwd %pycat %pylab %qtconsole %quickref %recall %rehashx %reload_ext %rep %rerun %reset %reset_selective %rm %rmdir %run %save %sc %store %sx %system %tb %time %timeit %unalias %unload_ext %who %who_ls %whos %xdel %xmode Available cell magics: %%! %%HTML %%SVG %%bash %%capture %%debug %%file %%html %%javascript %%latex %%perl %%prun %%pypy %%python %%python2 %%python3 %%ruby %%script %%sh %%svg %%sx %%system %%time %%timeit %%writefile Automagic is ON, % prefix IS NOT needed for line magics.
# Measuring Performance
%timeit range(1000)
%timeit xrange(1000)
100000 loops, best of 3: 13.9 µs per loop 10000000 loops, best of 3: 198 ns per loop
%%timeit
# Measuring Block Performance
for x in range(1000):
y=x+1
10000 loops, best of 3: 65.1 µs per loop
%%timeit
# Measuring Block Performance
for x in xrange(1000):
y=x+1
1000 loops, best of 3: 488 µs per loop
# Reset (Delete) all variables
%reset
Once deleted, variables cannot be recovered. Proceed (y/[n])? n Nothing done.
%%bash
echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
You have access to all code inside you code cell and the out put from them in two lists: In and Out.
3+5
8
In[18]
u'3+5'
Out[18]
8
_ + 3
11
_ - 4
7