Method summary
- __init__(self)
- visitReturn(self, node)
Methods
- __init__(self)
- visitReturn(self, node)
Inspect the return node's contents to see if it is filled with simple name variables that we can infer are the names of the return variables.
API Reference for Enthought Tool Suite 3.2.0
AST Visitor Class for finding the return_vals from a function.
return_vals is a list of lists. Each list is the set of variable names from a return statement in the function. For example:
>>> code = ''' ... def foo(x): ... if x: ... return vp, vs ... else: ... return vp ... ''' >>> import compiler >>> ast = compiler.parse(code) >>> walk(ast, ReturnVariablesFinder()).return_vals [['vp', 'vs'], ['vp']]
This will only return the values from functions that have simple return statements. For example
>>> code = ''' ... def foo(x): ... return bar(x) ... ''' >>> import compiler >>> ast = compiler.parse(code) >>> walk(ast, ReturnVariablesFinder()).return_vals [['result']]
fixme: Handle empty list return statement in some way.
Inspect the return node's contents to see if it is filled with simple name variables that we can infer are the names of the return variables.
© Copyright 2002-2009 Enthought, Inc.