Re: explicit variable scoping
"David MacQuigg" <dmq@gain.com > wrote in message
news:blbu505vrj 35i52ari8a0uivj a0pp7a9qu@4ax.c om...
[color=blue]
> If we want to set variables in intermediate scopes, I would prefer a
> syntax like:
>
> b = 1
> def f():
> a = 2
> def g():
> global.f.a = 3
> global.b = 4
>
> Of course, this means we also have to allow functions to have
> attributes.
>[/color]
Hi.
I know what you meant but, technically, functions can and do have
attributes, just not the kind you've mentioned (where the locals become
attributes of their function):
[color=blue][color=green][color=darkred]
>>> def f(): pass[/color][/color][/color]
....[color=blue][color=green][color=darkred]
>>> f.a = "A"
>>> f.a[/color][/color][/color]
'A'[color=blue][color=green][color=darkred]
>>>[/color][/color][/color]
Just so things are clear for those following along ...
Sean
"David MacQuigg" <dmq@gain.com > wrote in message
news:blbu505vrj 35i52ari8a0uivj a0pp7a9qu@4ax.c om...
[color=blue]
> If we want to set variables in intermediate scopes, I would prefer a
> syntax like:
>
> b = 1
> def f():
> a = 2
> def g():
> global.f.a = 3
> global.b = 4
>
> Of course, this means we also have to allow functions to have
> attributes.
>[/color]
Hi.
I know what you meant but, technically, functions can and do have
attributes, just not the kind you've mentioned (where the locals become
attributes of their function):
[color=blue][color=green][color=darkred]
>>> def f(): pass[/color][/color][/color]
....[color=blue][color=green][color=darkred]
>>> f.a = "A"
>>> f.a[/color][/color][/color]
'A'[color=blue][color=green][color=darkred]
>>>[/color][/color][/color]
Just so things are clear for those following along ...
Sean
Comment