[Python-Dev] Alternate notation for global variable assignments

Zack Weinberg zack at codesourcery.com
Sun Oct 26 13:14:37 EST 2003

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.


More information about the Python-Dev mailing list