Package joy :: Module misc
[hide private]
[frames] | no frames]

Module misc

source code


misc.py defines several useful functions that don't rightly belong in any obvious location

Functions
---------

curry -- Curry a function, returning a callable with the value of the initial parameters pre-selected. One of the mainstays of functional programming.

printExc -- Print a formatted stack-trace to standard error

loadCSV -- Load a CSV file into a list of lists

inlineCSV -- Similar to loadCSV, but takes the CSV text from a multiline python string

Functions [hide private]
 
curry(fn, *cargs, **ckwargs)
Curry a function, returning a callable with the value of the initial parameters pre-selected.
source code
 
printExc(exinfo=None)
Print a formatted stack-trace to standard error
source code
 
loadCSV(fn)
Load a CSV file into a list of lists, converting empty cells into None, numbers as floats and quoted strings as strings.
source code
 
inlineCSV(txt)
Similar to loadCSV, but takes the CSV text from a multiline python string, e.g.
source code
Function Details [hide private]

curry(fn, *cargs, **ckwargs)

source code 

Curry a function, returning a callable with the value of the
initial parameters pre-selected. For any function f
  curry(f,*arg0)(*arg1,**kw) f(x,*(arg0+arg1),**kw)
so, for example:
  f(x,y) = curry(f,x)(y) = curry(f,x,y)()

loadCSV(fn)

source code 

Load a CSV file into a list of lists, converting empty cells into None, numbers as floats and quoted strings as strings.

In addition to standard CSV format, empty (white only) lines and lines starting with "#" are ignored

inlineCSV(txt)

source code 

Similar to loadCSV, but takes the CSV text from a multiline python string, e.g.

>>> sheet = inlineCSV('''
... # Non-CSV Unix shell style comments and empty lines are ignored
... ,         "sparrow",  "banana"
... "weight", 5,          1
... ''')