Code Search for Developers
 
 
  

ip_embed-short.py from matplotlib at Krugle


Show ip_embed-short.py syntax highlighted

"""Quick code snippets for embedding IPython into other programs.

See example-embed.py for full details, this file has the bare minimum code for
cut and paste use once you understand how to use the system."""

#---------------------------------------------------------------------------
# This code loads IPython but modifies a few things if it detects it's running
# embedded in another IPython session (helps avoid confusion)

try:
    __IPYTHON__
except NameError:
    argv = ['']
    banner = exit_msg = ''
else:
    # Command-line options for IPython (a list like sys.argv)
    argv = ['-pi1','In <\\#>:','-pi2','   .\\D.:','-po','Out<\\#>:']
    banner = '*** Nested interpreter ***'
    exit_msg = '*** Back in main IPython ***'

# First import the embeddable shell class
from IPython.Shell import IPShellEmbed
# Now create the IPython shell instance. Put ipshell() anywhere in your code
# where you want it to open.
ipshell = IPShellEmbed(argv,banner=banner,exit_msg=exit_msg)
                            
#---------------------------------------------------------------------------
# This code will load an embeddable IPython shell always with no changes for
# nested embededings.

from IPython.Shell import IPShellEmbed
ipshell = IPShellEmbed()
# Now ipshell() will open IPython anywhere in the code.

#---------------------------------------------------------------------------
# This code loads an embeddable shell only if NOT running inside
# IPython. Inside IPython, the embeddable shell variable ipshell is just a
# dummy function.

try:
    __IPYTHON__
except NameError:
    from IPython.Shell import IPShellEmbed
    ipshell = IPShellEmbed()
    # Now ipshell() will open IPython anywhere in the code
else:
    # Define a dummy ipshell() so the same code doesn't crash inside an
    # interactive IPython
    def ipshell(): pass

#******************* End of file <example-embed-short.py> ********************




See more files for this project here

matplotlib

Matplotlib is a pure python plotting library with the goal of making\r\npublication quality plots using a syntax familiar to matlab users. \r\nThe library uses Numeric for handling large\r\ndata sets and supports a variety of output backends

Project homepage: http://sourceforge.net/projects/matplotlib
Programming language(s): C,C++,Python
License: other

  scipy/
    bessel.py
    example1.1
    example10.2.1
    example10.2.2
    example10.2.3
    example10.2.5
    example10.3.1
    example10.3.2
    example10.3.6
    example10.4.4
    example2.1
    example2.2
    example2.3
    example3.1
    example3.2
    example4.1
    example4.2
    example4.3
    example4.4
    example4.5
    example4.6
    example5.1
    example5.2
    example5.3
    example5.4
    example5.5
    example5.6
    example5.7
    example5.8
    example5.9
    example6.1
    example6.2
    example6.3
    example6.4
    least_squares_fit.py
    roots1d.py
  .matplotlibrc
  README
  WallisPi.py
  WindowLevelInterface.py
  __init__.py
  colors.py
  erathostenes.py
  ip_embed-short.py
  ip_embed.py
  ip_expensive_init.py
  ip_simple.py
  ip_simple2.py
  mayavi_bighead.py
  mpl_agg_oo.py
  mpl_image_ratner.py
  mpl_imshow.py
  mpl_pylab.py
  mpl_set_get.py
  mpl_subplot_demo.py
  parse_file.py
  runall.py
  vtk_hello.py
  vtk_marching_cubes.py
  vtk_slice_viewer.py
  weave_callback.py
  weave_cplx.py
  weave_examples.py
  wrap_f2py_setup.py
  wrap_weave.py