[Python-ideas] binding vs rebinding

Blake Winton bwinton at latte.ca
Fri Feb 6 15:38:50 CET 2009


spir wrote:
 > I assert that the same name should not be used for both special
 > and standard cases. This imo shows a lack of distinction. Using
 > a different name will make things clearer:

I assert that once you've gotten to the point of suggesting that people 
change the way they program, you've lost the debate.  :)

"Practicality beats purity."

How many other languages support this split between binding and 
rebinding?  How many of them are popular?  (What's the highest rank that 
one of them has on, say, 
http://www.tiobe.com/content/paperinfo/tpci/index.html ?)

(Don't take this to mean that I disagree with you.  I think that if 
people either had to say when they were rebinding names, or couldn't 
rebind names (a la Erlang), programs would probably be more stable.  But 
Python isn't the kind of language to do that sort of thing in.  I feel 
it would fit in better with a more academic language like Haskell or 
Scheme.)

> Probably most name rebindings rather express a lack of distinction
 > that makes the code obscure. Haven't you ever read things like:
> 
> config = "config.txt"	# string: name
> config = open(config)	# file object
> config = config.read()	# string: content
> config = config.lines()	# array of strings
> config = parse(config)	# e.g. custom object

I don't see that code as particularly obscure.  Sure you could re-write 
it to use a billion different temporary variables (but you'ld better 
make sure they didn't conflict with ones above you!), but that doesn't 
really help anything from my point of view, and this example (with the 
addition of some extra syntax) would still be legal in the 
rebinding-version of Python you're suggesting.

Later,
Blake.



More information about the Python-ideas mailing list