Understanding the pythonic way: why a.x = 1 is better than a.setX(1) ?

Terry Reedy tjreedy at udel.edu
Fri Sep 5 09:03:43 CEST 2008



Marco Bizzarri wrote:

> I understand that Python is a balance between different forces (like
> any software object around the world) and I'm simply asking some
> pointers to the discussion leading to this balance.

The original decisions by Guido were nearly 20 years ago and other 
discussions are scattered through the archive of this and the py-dev 
list.  But here is a pointer.  Why go through the trouble of writing 
functions that will set, get, and delete an attribute and the trouble of 
calling those functions when you can use Python's existing syntax to do 
it directly?  More particularly, why would/should Guido force the 
combersome indirection and time-penalty for writing, reading, and 
execution on *every* Python programmer?

Of course, from my viewpoint, and for my usage,languages that do so 
force are obnoxious.

tjr




More information about the Python-list mailing list