Accessors in Python (getters and setters)

mystilleef mystilleef at gmail.com
Thu Jul 13 04:59:36 EDT 2006


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.

> Ciao,
> 	Marc 'BlackJack' Rintsch




More information about the Python-list mailing list