modifying static (local) method variables
Steve Holden
steve at holdenweb.com
Fri Nov 12 11:57:48 EST 2004
More information about the Python-list mailing list
Fri Nov 12 11:57:48 EST 2004
- Previous message (by thread): Majordomo results: Hey!
- Next message (by thread): modifying static (local) method variables
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
t scytale wrote: > i am using a mutable default paramater to simulate a static method variable. > i notice that > - assigning to the var inside the method causes it to return to the > default value at each call. > - appending to the var gives the expected behaviour (the value is > preserved to the next call > > why is this? > Because an assignment to an argument inside the method merely rebinds the local variable for the remainder of that execution. Mutating the referenced object ensures that the changed value is available to further calls. regards Steve -- http://www.holdenweb.com http://pydish.holdenweb.com Holden Web LLC +1 800 494 3119
- Previous message (by thread): Majordomo results: Hey!
- Next message (by thread): modifying static (local) method variables
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list