17.01.2015 Views

py Documentation - Read the Docs

py Documentation - Read the Docs

py Documentation - Read the Docs

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>py</strong> <strong>Documentation</strong>, Release 1.4.27.dev1<br />

insert()<br />

L.insert(index, object) – insert object before index<br />

pop([index]) → item – remove and return item at index (default last).<br />

Raises IndexError if list is empty or index is out of range.<br />

remove()<br />

L.remove(value) – remove first occurrence of value. Raises ValueError if <strong>the</strong> value is not present.<br />

reverse()<br />

L.reverse() – reverse IN PLACE<br />

sort()<br />

L.sort(cmp=None, key=None, reverse=False) – stable sort IN PLACE; cmp(x, y) -> -1, 0, 1<br />

3.2.4 <strong>py</strong>.code.Frame<br />

Frame wrappers are used in <strong>py</strong>.code.Traceback items, and will usually not directly be instantiated. They provide<br />

some nice methods to evaluate code ‘inside’ <strong>the</strong> frame (using <strong>the</strong> frame’s local variables), get to <strong>the</strong> underlying code<br />

(frames have a code attribute that points to a <strong>py</strong>.code.Code object) and examine <strong>the</strong> arguments.<br />

Example (using <strong>the</strong> ‘first’ TracebackItem instance created above):<br />

>>> frame = first.frame<br />

>>> isinstance(frame.code, <strong>py</strong>.code.Code)<br />

True<br />

>>> isinstance(frame.eval(’self’), <strong>py</strong>.path.local)<br />

True<br />

>>> [namevalue[0] for namevalue in frame.getargs()]<br />

[’cls’, ’path’]<br />

class <strong>py</strong>.code.Frame(frame)<br />

Wrapper around a Python frame holding f_locals and f_globals in which expressions can be evaluated.<br />

statement<br />

statement this frame is at<br />

eval(code, **vars)<br />

evaluate ‘code’ in <strong>the</strong> frame<br />

‘vars’ are optional additional local variables<br />

returns <strong>the</strong> result of <strong>the</strong> evaluation<br />

exec_(code, **vars)<br />

exec ‘code’ in <strong>the</strong> frame<br />

‘vars’ are optiona; additional local variables<br />

repr(object)<br />

return a ‘safe’ (non-recursive, one-line) string repr for ‘object’<br />

getargs(var=False)<br />

return a list of tuples (name, value) for all arguments<br />

if ‘var’ is set True also include <strong>the</strong> variable and keyword arguments when present<br />

22 Chapter 3. <strong>py</strong>.code: higher level <strong>py</strong>thon code and introspection objects

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!