Le Fri, 08 May 2009 22:31:57 +0200,
Pascal Chambon <chambon.pascal@wanadoo.fr> s'exprima ainsi:
And no one seemed to enjoy the possibilities of getting "potentially
static variables" this way. Static variables are imo a rather bad idea,
since they create "stateful functions", that make debugging and
maintenance more difficult ; but when such static variable are,
furthermore, potentially non-static (i.e when the corresponding function
argument is supplied), I guess they become totally useless and dangerous
- a perfect way to get hard-to-debug behaviours.
If we want static vars, there are better places than default args for this. (See also the thread about memoizing). E.g. on the object when it's a method, or even on the func itself.
def squares(n):
square = n * n; print square
if square not in squares.static_list:
squares.static_list.append(n)
squares.static_list = []
squares(1);squares(2);squares(1);squares(3)
print squares.static_list
Denis
------
la vita e estrany
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
http://mail.python.org/mailman/listinfo/python-ideas
Well, I've just realized I'd sent a semi-dumb question in my previous
answer :p