[Python-Dev] PEP 8 updates/clarifications

Jim Fulton jim at zope.com
Mon Dec 12 12:41:39 CET 2005


Raymond Hettinger wrote:
>>Do not use accessor methods, like ``obj.getFoo()`` and
>>``obj.setFoo(v)``, instead just expose a public attribute
> 
> (``obj.foo``).
> 
> This advice is, of course, not appropriate for all users (properties are
> not typically in a Python beginner's skill set)

Really? In any case, properties are only needed if you change
your mind about the implementation.  In my experience, they are
rarely needed.

 > or all use cases.

I think the advice gave a very narrow case, which was when you were going
to write trivial accessors.

 >  It is
> closer to one person's view of the One-Right-Way(tm).  Opinions on
> programming best practices vary widely, evolve over time, and may be
> context dependent.

I thought I was reflecting more than just my opinion.
Also, the original text had just as strong an admonition --
one that, as I mentioned, seem to be out of line with
current thinking.

...

>>>experience (for everyone I know) has shown them to be an attractive
>>>nuisance.  I recommend discouraging them.
>>
>>I really really hate double underscores
> 
> 
> FWIW, I think we have no business dictating to others how they should
> name their variables.  This is doubly true for a convention that has a
> long history and built-in language support.

Even if, experience with a practice has shown it to be highly
problematic?

> My preference is to leave PEP 8 for the minimum practices necessary for
> one programmer to be able to read and maintain another programmer's
> code.

I'm for making the style guide smaller.  I do think it offers too
much advice in places.  Although I'm not sure we could all agree
om what those places are. :)

Jim

-- 
Jim Fulton           mailto:jim at zope.com       Python Powered!
CTO                  (540) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org


More information about the Python-Dev mailing list