RE: [Python-Dev] Alternate notation for global variable assignments

First of all, I'm strongly *against* the idea of :var. However, I think a syntax that would work with no ambiguities, and not look too bad, would be: .var e.g. sublist = lst[.var] I would also be strongly against this suggestion - it simply deals with the problems I see with the current suggestion. It has its own problems, including (but not limited to) not being very obvious. Tim Delaney

On Mon, 2003-10-27 at 19:00, Delaney, Timothy C (Timothy) wrote:
What I really want is access to a namespace, and then all the normal Python attribute access notations just work. They're one honking great idea after all. This was behind the "import __me__" suggestion for access to module globals. Why can't we have something similar for nested functions? -Barry

On Tuesday 28 October 2003 01:11 am, Barry Warsaw wrote: ...
Yes, all in all this does remain my preference, too. I'd take stropping (or "keyword stropping" a la Greg's "outer x") rather than declarative stuff, but just getting a namespace (in ways the compiler could recognize, i.e. by magicnames such as __me__) and then using __me__.x=23 would require no new syntax and be maximally obvious. Sigh.
This was behind the "import __me__" suggestion for access to module globals. Why can't we have something similar for nested functions?
And why can't we have "import __me__" too? Ah well! Alex

At 10:31 AM 10/28/03 +0100, Alex Martelli wrote:
Why not just: import whatevermynameis whatevermynameis.foo = bar This would be even *more* maximally obvious, as you wouldn't need to know what '__me__' means. :) And how often do you write a module without knowing what its name is, or change the name after you've written it? Plus, thanks to the time machine, it already works. :) Heck, now that I've thought of it, I'm almost tempted to go change all my existing uses of global to this instead...

Doesn't work when your module may either be called __main__ or rumpelstiltkin. It would then become if __name__ == "__main__": import __main__ as me else: import rumpelstiltkin as me which loses the "aha!" effect of a cool solution. It also IMO requires too much explanation to the unsuspecting reader who doesn't understand right away *why* rumpelstiltkin imports itself. --Guido van Rossum (home page: http://www.python.org/~guido/)

Guido van Rossum strung bits together to say:
I believe someone else also suggested that if rumpelstiltskin should be imported as: import fairytales.rumpelstiltskin then a bare import is going to have trouble, even inside the module. Cheers, Nick. -- Nick Coghlan | Brisbane, Australia ICQ#: 68854767 | ncoghlan@email.com Mobile: 0409 573 268 | http://www.talkinboutstuff.net "Let go your prejudices, lest they limit your thoughts and actions."

No; I want to reserve .var for the "with" statement (a la VB). --Guido van Rossum (home page: http://www.python.org/~guido/)

On Mon, 2003-10-27 at 19:00, Delaney, Timothy C (Timothy) wrote:
What I really want is access to a namespace, and then all the normal Python attribute access notations just work. They're one honking great idea after all. This was behind the "import __me__" suggestion for access to module globals. Why can't we have something similar for nested functions? -Barry

On Tuesday 28 October 2003 01:11 am, Barry Warsaw wrote: ...
Yes, all in all this does remain my preference, too. I'd take stropping (or "keyword stropping" a la Greg's "outer x") rather than declarative stuff, but just getting a namespace (in ways the compiler could recognize, i.e. by magicnames such as __me__) and then using __me__.x=23 would require no new syntax and be maximally obvious. Sigh.
This was behind the "import __me__" suggestion for access to module globals. Why can't we have something similar for nested functions?
And why can't we have "import __me__" too? Ah well! Alex

At 10:31 AM 10/28/03 +0100, Alex Martelli wrote:
Why not just: import whatevermynameis whatevermynameis.foo = bar This would be even *more* maximally obvious, as you wouldn't need to know what '__me__' means. :) And how often do you write a module without knowing what its name is, or change the name after you've written it? Plus, thanks to the time machine, it already works. :) Heck, now that I've thought of it, I'm almost tempted to go change all my existing uses of global to this instead...

Doesn't work when your module may either be called __main__ or rumpelstiltkin. It would then become if __name__ == "__main__": import __main__ as me else: import rumpelstiltkin as me which loses the "aha!" effect of a cool solution. It also IMO requires too much explanation to the unsuspecting reader who doesn't understand right away *why* rumpelstiltkin imports itself. --Guido van Rossum (home page: http://www.python.org/~guido/)

Guido van Rossum strung bits together to say:
I believe someone else also suggested that if rumpelstiltskin should be imported as: import fairytales.rumpelstiltskin then a bare import is going to have trouble, even inside the module. Cheers, Nick. -- Nick Coghlan | Brisbane, Australia ICQ#: 68854767 | ncoghlan@email.com Mobile: 0409 573 268 | http://www.talkinboutstuff.net "Let go your prejudices, lest they limit your thoughts and actions."

No; I want to reserve .var for the "with" statement (a la VB). --Guido van Rossum (home page: http://www.python.org/~guido/)
participants (6)
-
Alex Martelli
-
Barry Warsaw
-
Delaney, Timothy C (Timothy)
-
Guido van Rossum
-
Nick Coghlan
-
Phillip J. Eby