Accessors in Python (getters and setters)

Steve Holden steve at holdenweb.com
Fri Jul 14 03:56:03 EDT 2006


mystilleef wrote:
> Marc 'BlackJack' Rintsch wrote:
> 
>>In <1152778446.236509.151730 at 35g2000cwc.googlegroups.com>, mystilleef
>>wrote:
>>
>>
>>>Maric Michaud wrote:
>>>
>>>>But that's not python philosophy.
>>>
>>>Python doesn't have any philosophy with regards to naming identifiers.
>>
>>But the python community has one.  Pythonistas prefer readable source code
>>so they tend to think about good names.  As The Zen of Python says
>>"Readability counts."
> 
> I'm glad I'm in tune with the "python community."
> 
>>>>But they are in Python and that is the python's philosophy. All attribute or
>>>>method not beginning with an '_' *is* API.
>>>
>>>Right, and what if I want to change a private API to a public one. How
>>>does that solve my naming issues.
>>
>>Then you have to change all references to that private attribute.  What's
>>the problem here?  As it was private I would expect to find all the
>>references "nearby" in the same module or class.
> 
> Right, but tmp isn't private.
> 
>>>>And in python the reverse can be true :
>>>
>>>The reverse is hardly ever true. 90% of public APIs in almost all
>>>languages are methods or functions.
>>
>>Except the ones with properties where ordinary "attributes" may be just
>>calls in disguise.
> 
> 
> Crap! Even in Python too most Public APIs are methods and functions.
> 
> 
>>Python is not almost all other languages and in Python code you usually
>>won't find those trivial getters and setters because we have properties if
>>the access might become a bit more complex in the future.
>>
> 
> 
> Ha! I bet you haven't read too many Python codes.
> 
> 
One thing I can more or less guarantee is that if you'd invested the 
time you've spent on this thread in actually performing whatever trivial 
but tedious engineering work was required to achieve the renaming of 
that attribute the job would have been completed long ago.

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd          http://www.holdenweb.com
Skype: holdenweb       http://holdenweb.blogspot.com
Recent Ramblings     http://del.icio.us/steve.holden




More information about the Python-list mailing list