On 30/06/2013 3:46 PM, Ian Kelly wrote:
In general I agree, although when reading code I would definitely
prefer if the locals were declared.

If you import the code into the interpreter as an adjunct to reading it
you can see the locals with:

>>> somefunc.func_code.co_varnames # 2.x
>>> somefunc.__code__.co_varnames  # 3.x

On a related note, I think that generator functions should in some way
be explicitly marked as such in the declaration, rather than needing
to scan the entire function body for a yield statement to determine
whether it's a generator or not.

>>> inspect.isgenerator(somefunc)

However, a dedicated code reader built around the inspect module could
be a handy tool.

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to