static variables

Erik python at lucidity.plus.com
Tue Dec 1 20:16:37 EST 2015


On 02/12/15 01:02, Steven D'Aprano wrote:
> On Tue, 1 Dec 2015 08:15 pm, Grobu wrote:
>> # -------------------------------------------------
>>   >>> def test(arg=[0]):
>> ...     print arg[0]
>> ...     arg[0] += 1
> Awesome!

Hideous!

> using a mutable default as static storage.

Exposing something a caller can override as a local, static, supposedly 
"private" value is IMHO a tad ... ugly? (*)

E.

(*) No I don't want to resurrect that thread.



More information about the Python-list mailing list