[Python-Dev] Explicit Lexical Scoping (pre-PEP?) (original) (raw)
Fredrik Lundh fredrik at pythonware.com
Thu Jul 13 00:13:51 CEST 2006
- Previous message: [Python-Dev] Explicit Lexical Scoping (pre-PEP?)
- Next message: [Python-Dev] Explicit Lexical Scoping (pre-PEP?)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Boris Borcic wrote:
note that most examples of this type already work, if the target type is mutable, and implement the right operations:
def counter(num): num = mutableint(num) def inc(): num += 1 return num return inc I agree with you (and argued it in "scopes vs augmented assignment vs sets" recently) that mutating would be sufficient /if/ the compiler would view augmented assignment as mutations operators
feel free to replace that += with an .add(1) method call; the point wasn't the behaviour of augmented assigment, the point was that that the most common use pattern involves mutation of the target object.
the syntax isn't that important, really.
- Previous message: [Python-Dev] Explicit Lexical Scoping (pre-PEP?)
- Next message: [Python-Dev] Explicit Lexical Scoping (pre-PEP?)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]