{ "metadata": { "name": "breakout" }, "nbformat": 2, "worksheets": [ { "cells": [ { "cell_type": "markdown", "source": [ "# IPython Intro Breakout Session", "", "Interactive exploration", "-----------------------", "", "I have shown you the Zen of Python. But if you search through all of the python", "source code, you will not find the word \"Zen\" anywhere.", "", "", "", "Use ``, `?` and `??` on the `this` module to decode this string:" ] }, { "cell_type": "code", "collapsed": true, "input": [ "import this", "", "secret = \"Tbbq Wbo! abj tb fvta hc sbe gur znvyvat yvfg bire ng vclguba.bet\"" ], "language": "python", "outputs": [] }, { "cell_type": "markdown", "source": [ "Timing information", "------------------", "", "", "", "Josh mentioned that there are two range commands, `range` and `xrange`. ", "", "", "", "Run the code below to see which one is faster, and then read the documentation for the two to see why this is the case." ] }, { "cell_type": "code", "collapsed": true, "input": [ "timeit?" ], "language": "python", "outputs": [] }, { "cell_type": "code", "collapsed": true, "input": [ "%timeit range(100)" ], "language": "python", "outputs": [] }, { "cell_type": "code", "collapsed": true, "input": [ "%timeit xrange(100)" ], "language": "python", "outputs": [] }, { "cell_type": "markdown", "source": [ "Configuration file options", "--------------------------", "", "Create the stub default profile (if you haven't already)", "", "", "", " $ ipython profile create", "", "", "", "This will create the stubs for the default profile", "", "now you can change these defaults.", "", "", "", "To find where your profile is stored:", "", "", "", " In [1]: import IPython", "", " In [2]: IPython.utils.path.locate_profile()", "", "", "", "Example:if you want the `_` and `__` methods to show up by default when doing tab-completion ", "", "", "", " c.IPCompleter.omit__names", "", "Another example: you can add your own startup message (or execute your desired commands at startup) like I have:", "", " .../profile_default/startup/README", "", "", "", "", "", "", " " ] }, { "cell_type": "code", "collapsed": false, "input": [ "import IPython", "IPython.utils.path.locate_profile()" ], "language": "python", "outputs": [ { "output_type": "pyout", "prompt_number": 2, "text": [ "u'/home/pi/.ipython/profile_default'" ] } ], "prompt_number": 2 }, { "cell_type": "code", "collapsed": false, "input": [ "IPython.utils.path.locate_profile()+'/startup/README'" ], "language": "python", "outputs": [ { "output_type": "pyout", "prompt_number": 3, "text": [ "u'/home/pi/.ipython/profile_default/startup/README'" ] } ], "prompt_number": 3 }, { "cell_type": "code", "collapsed": true, "input": [ "cat IPython.utils.path.locate_profile()+'/startup/README'" ], "language": "python", "outputs": [] } ] } ] }