On 06/15/2015 06:20 PM, Ben Finney wrote:
> I'm surprised by your assertion. To my mind, outside callers get simple
> and direct access to the attribute, whereas the code of the function
> itself does not have such easy access; unlike ‘self’ for the current
> instance of a class, there's no obvious name to use for referring to the
> function object within the function object's own code.

Of course it has access, and it's obvious and easy as well:

def foo():
    foo.flag = True

The only thing I'm not sure of is a clean way to test for the
attribute's existence.  The __init__.py of a package, or the
initialization code of the module could preset the attribute, though.

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

Reply via email to