[Baypiggies] PEP-8 Style Interpretation Question

Glen Jarvis glen at glenjarvis.com
Thu May 15 22:40:42 CEST 2008


Have you noticed that we have almost 'religious' discussions in the  
Computer Science community about things some people wouldn't give a  
hill of beans about? =)

I disagree with a fellow BayPIGgier on interpretation of the PEP-8  
standard.

The discussion revolves around code of this nature (obviously a cooked  
example where it is not necessary to place each attribute of demo on a  
new line. Comments omitted purposely):

def demo(
         first_attribute,
         second_attribute
         ):
     print "spam"

I believe this breaks PEP-8 coding standards (http://www.python.org/dev/peps/pep-0008/ 
) with regard to "White Space in Expressions and Statements." The  
guide states "Avoid extraneous whitespace in the following  
situations...Immediately inside parentheses, brackets or braces."

However, the argument is that the '\n' character isn't a white space  
character.

I feel that it is because of the following:

 >>> x='\n';
 >>> print x


 >>> x.isspace()
True

And, according to the standard library, we see:
isspace(	)
Return true if there are only whitespace characters in the string and  
there is at least one character, false otherwise.
For 8-bit strings, this method is locale-dependent

I also feel that the parenthesis on a new line like this is C-like,  
artificially creating program blocks when in those days, there was  
nothing to enforce it. If I were writing C, I may well actually follow  
the above.

I also feel that Python enforces this block with indentation, so the  
artificial construct isn't necessary and is 'anti-pythonic.' The more  
pythonic approach to me seems:


def demo(first_attribute,
                   second_attribute):
     print "spam"

I could compromise to
def demo(
     first_attribute,
     second_attribute):

     print "spam"

because this keeps the attributes clearly indented inside the def.  
However, there is a 'no white space after open parenthesis rule too...


I am *NOT* looking for arguments where I'm right. I'm looking for  
arguments where I'm WRONG!!! I want to be very strict ad adhering to  
industry coding practices and keeping good coding habits on projects I  
work on. But, if the above *IS* a good coding habit, I'd like to know  
about it. I want to be argued with.

The above feels very 'anti-pythonic' to me.... But, I could be  
wrong... I really like working with this individual, so if I'm wrong,  
I can still feel I'm following industry standards and code their way  
with them..

Please keep in mind that the other person is a bayPIGgier too and  
someone I respect incredibly... So, flame me if you must... but, not  
them... We all have different beliefs on things...



Thanks for all of the help...


Warmest Regards,


Glen Jarvis
--
415-680-3964
glen at glenjarvis.com
http://www.glenjarvis.com

"You must be the change you wish to see in the world." -M. Gandhi


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/baypiggies/attachments/20080515/a886fe45/attachment.htm>


More information about the Baypiggies mailing list