Antoon Pardon wrote:

> I disagree here. The problem with "global", at least how it is
> implemented in python, is that you only have access to module
> scope and not to intermediate scopes.
> 
> I also think there is another possibility. Use a symbol to mark
> the previous scope. e.g. x would be the variable in local scope.
> @.x would be the variable one scope up. @[EMAIL PROTECTED] would be the
> variable two scopes up etc.

Looks like what you want is easier introspection and the ability to get 
the parent scope from it in a simple way.  Maybe something like a 
builtin '__self__' name that contains the information, then a possible 
short 'sugar' method to access it.   '__self__.__parent__', would become 
@ in your example and '__self__.__perent__.__self__.__parent__' could 
become @[EMAIL PROTECTED]

Somthing other than '@' would be better I think.  A bare leading '.' is 
another possiblity.  Then '..x' would be the x two scopes up.

This isn't the same as globals. Globals work the way they do because if 
they weren't automatically visible to all objects in a module you 
wouldn't be able to access any builtin functions or class's without 
declaring them as global (or importing them) in every function or class 
that uses them.

Cheers,
Ron












-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to