OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Mar 19, 2024 3:53 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Python PEP8 Naming
PostPosted: Wed Nov 04, 2015 3:24 pm 
Offline
Member
Member

Joined: Fri Feb 15, 2013 9:29 pm
Posts: 35
I have a hard time following the Python PEP 8 when it comes to the naming convention:
Quote:
Function names should be lowercase, with words separated by underscores as necessary to improve readability.

mixedCase is allowed only in contexts where that's already the prevailing style (e.g. threading.py), to retain backwards compatibility.


Yet we see countless times in python where they break their own guild lines:
str.startswith()
file.readlines()
etc..

I like to use camelCase for my function names, and I see no issue with others using lower_case, but I fail to understand how PEP8 can require us to use 'lower_case' when python itself uses 'lowercase' (no underscore) in many situations.

Just rambling,
Trevor

_________________
Programming is like fishing, you must be very patient if you want to succeed.


Top
 Profile  
 
 Post subject: Re: Python PEP8 Naming
PostPosted: Wed Nov 04, 2015 4:34 pm 
Offline
Member
Member
User avatar

Joined: Wed Jan 06, 2010 7:07 pm
Posts: 792
Probably for the same reason that they allow mixedCase- for backwards compatibility. They just want as much code as is reasonable to have the same style, for consistency.

_________________
[www.abubalay.com]


Top
 Profile  
 
 Post subject: Re: Python PEP8 Naming
PostPosted: Fri Nov 06, 2015 1:52 pm 
Offline
Member
Member

Joined: Tue Jan 21, 2014 10:16 am
Posts: 56
Quote:
Yet we see countless times in python where they break their own guild lines:
str.startswith()
file.readlines()
etc..


Probably underscores weren't deemed necessary to improve readability in this cases.


Top
 Profile  
 
 Post subject: Re: Python PEP8 Naming
PostPosted: Tue Nov 10, 2015 4:15 am 
Offline
Member
Member

Joined: Tue Feb 26, 2008 10:47 am
Posts: 89
Location: Sweden
PEP 8 is a recommendation, not a law. What's important is the spirit.

Code:
>>> import this


Also see - if you haven't - the PyCon talk: Beyond PEP 8 by Raymond Hettinger.

_________________
Blawg


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: SemrushBot [Bot], Solar and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group