[Python-Dev] nested scopes confusion (original) (raw)
Thomas Heller thomas.heller@ion-tof.com
Tue, 4 Dec 2001 20:58:59 +0100
- Previous message: [Python-Dev] nested scopes confusion
- Next message: [Python-Dev] nested scopes confusion
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Yes, you're out of luck. Like in all decent languages with nested scope, Python binds to the variable, not to its value at the time the inner function is defined.
So nested scopes are not really an alternative (at least in this case) to the 'lambda self, i=i: i' trick.
> How do I achieve the desired effect? Note that the default argument > trick (def mth(i=i): ...) does not work because *args is present. Use a class with a call method:
That's what I was trying to avoid, because it is too slow.
Thanks,
Thomas
- Previous message: [Python-Dev] nested scopes confusion
- Next message: [Python-Dev] nested scopes confusion
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]