using "private" parameters as static storage?
Bruno Desthuilliers
bruno.42.desthuilliers at websiteburo.invalid
Fri Nov 14 11:01:31 EST 2008
Matimus a écrit :
> On Nov 13, 9:16 am, Joe Strout <j... at strout.net> wrote:
(snip)
>> def spam2():
>> if not hasattr(spam2,'count'):spam2.count=0
>> spam2.count += 1
>> return "spam2 " * spam2.count
>
>
> This is definitely preferred over the first.
I beg to disagree. This solution stores "count" on *whatever* the name
"spam2" resolves at runtime.
(snip)
More information about the Python-list
mailing list