[Python-Dev] Alternate notation for global variable assignments
Steve Holden
sholden at holdenweb.com
Mon Oct 27 16:25:56 EST 2003
> -----Original Message-----
> From: python-dev-bounces+sholden=holdenweb.com at python.org
> [mailto:python-dev-bounces+sholden=holdenweb.com at python.org]On
> Behalf Of
> Zack Weinberg
> Sent: Sunday, October 26, 2003 1:15 PM
> To: python-dev
> Subject: [Python-Dev] Alternate notation for global variable
> assignments
>
>
>
> I like Just's := concept except for the similarity to =, and I worry
> that the presence of := in the language will flip people into "Pascal
> mode" -- thinking that = is the equality operator. I also think that
> the notation is somewhat unnatural -- "globalness" is a property of
> the _variable_, not the operator. So I'd like to suggest instead
>
> :var = value # var in module scope
> :scope:var = value # var in named enclosing scope
>
> An advantage of this notation is that it can be used anywhere, not
> just in an assignment. This has primary value for people reading the
> code -- if you have a fairly large class method that uses a module
> variable (not by assigning it) somewhere in the middle, writing it
> :var means the reader knows to go look for the assignment way up top.
> This should obviously be optional, to preserve backward compatibility.
>
However, its use in such expressions as
sublist = lst[:var]
would lead to substantial ambiguities, right?
regards
--
Steve Holden +1 703 278 8281 http://www.holdenweb.com/
Improve the Internet http://vancouver-webpages.com/CacheNow/
Python Web Programming http://pydish.holdenweb.com/pwp/
Interview with GvR August 14, 2003 http://www.onlamp.com/python/
More information about the Python-Dev
mailing list