"eryksun ()" <eryk...@gmail.com> writes:

>
> Regarding this I have question about function attributes. Is there an
> equivalent of 'self' for functions? I've seen people use function
> attributes as local static variables, but this seems problematic when
> all you have is a global reference to the function. The original
> reference might get deleted. Then when your function tries to
> reference its 'static' variable you'll get a NameError exception. For
> example:
>
> In [1]: def test1(n):
>    ...:     test1.a = n
>
> In [2]: test1(10); test1.a
> Out[2]: 10
>
> In [3]: test2 = test1; test2.a
> Out[3]: 10
>

[...]

I had never seen such a thing, but why would this make sense at all?
When does it make sense logically for a function to have an attribute?

A function should have some input, some local variables to compute
temporary results and a return value, I think nothing more...
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to