@chapters
@ipy-startup
b
Some classes P
File-like access
csv data
String list
slist to leo
Class tests
csvr
tempfile
rfile
strlist
Direct variables
bar
?
?Direct children of this node will be pushed at ipython bridge startup
This node itself will *not* be pushed
print "world"
def rfile(body,n):
""" @cl rfile
produces a StringIO (file like obj of the rest of the body) """
import StringIO
return StringIO.StringIO(body)
def tmpfile(body,n):
""" @cl tmpfile
Produces a temporary file, with node body as contents
"""
import tempfile
h, fname = tempfile.mkstemp()
f = open(fname,'w')
f.write(body)
f.close()
return fname
@cl tmpfile
Hello
?
@cl rfile
These
lines
should
be
readable
@others
def csvdata(body,n):
import csv
d = csv.Sniffer().sniff(body)
reader = csv.reader(body.splitlines(), dialect = d)
return reader
@cl csvdata
a,b,b
1,2,2
@cl
"hello world"
import IPython.genutils
def slist(body,n):
return IPython.genutils.SList(body.splitlines())
@cl slist
hello
world
on
many
lines
import ipy_leo
@ipy_leo.format_for_leo.when_type(IPython.genutils.SList)
def format_slist(obj):
return "@cl slist\n" + obj.n