Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
import rlcompleter, readline
readline.parse_and_bind('tab: complete')
%page? #pager
%pdef # prints definition headers
%pdoc # prints docstring of function
%pfile # run given file containing an object if found
%pinfo # provides information (type, base class, namespace, docstr)
%psource # show source for given element
%psearch # look for python objects by name
%history #provides access to the history via readline
%store # persist your macros and plain python variables
%reset # deletes all variables from the interactive namespace
%macro # lets you define a block of code that can be executed later inline
%run # executes the specified file in iPython
%save # save the specified input lines to specified output
goodnight~
#!/usr/bin/env python
groceries=['bread', 'milk', 'eggs', 'bacon', 'peanut butter']
for grocery in groceries:
print grocery
#!/usr/bin/env python
print "Welcome."
while 1:
command = raw_input('enter command: ')
if command == 'help':
print "Type quit to exit."
if command == 'quit':break
#!/usr/bin/env python
def plusten(y):
return y+10
print plusten(87)
print '''This is a multiline statement
you can say as much as you need here
and noone can say a damn thing..'''
print '''
Python Escape Sequences
\\newline ignored
\\\ backslash
\\' single quote
\\" double quote
\\a ascii bell
\\b ascii backspace
\\f ascii form feed