[Python-Dev] PEP 8 updates/clarifications

Barry Warsaw barry at python.org
Mon Dec 12 19:16:22 CET 2005


On Fri, 2005-12-09 at 17:19 -0600, Ian Bicking wrote:

> I personally feel "cls" should be used for classmethods, and not 
> elsewhere.  Just like I wouldn't like someone using "self" outside of 
> the first argument of instance methods.  So class_ still would be a good 
> spelling elsewhere.

Here's what I've written:

    Function and method arguments

      Always use 'self' for the first argument to instance methods.

      Always use 'cls' for the first argument to class methods.

      If a function argument's name clashes with a reserved keyword, it is
      generally better to append a single trailing underscore rather than use
      an abbreviation or spelling corruption.  Thus "print_" is better than
      "prnt".

> I looked at that too, but most of these didn't jump out at me.  I'll 
> copy in the parts that aren't already in PEP 8 that seem possible:
> 
>    From-imports should follow non-from imports.  Dotted imports should 
> follow
>    non-dotted imports.  Non-dotted imports should be grouped by increasing
>    length, while dotted imports should be grouped roughly alphabetically.
> 
> This seems too complex to me for PEP 8.

Really?  ISTR adopting this convention from Guido, but I'm not 100% sure
about that.  After having used it for several years now, I do really
like this style, but I'm willing to leave the recommendation out of PEP
8.

-Barry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 307 bytes
Desc: This is a digitally signed message part
Url : http://mail.python.org/pipermail/python-dev/attachments/20051212/6211e78a/attachment.pgp


More information about the Python-Dev mailing list