r/Python • • Jun 23 '14

Writing better python code

https://gist.github.com/kracekumar/09a60ec75a4de19b346e
143 Upvotes

126 comments sorted by

View all comments

14

u/Husio Jun 23 '14

Although very old, still contains a lot of important examples http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html

4

u/mariox19 Jun 23 '14
  • joined_lower for functions, methods, attributes

  • joined_lower or ALL_CAPS for constants

  • StudlyCaps for classes

  • camelCase only to conform to pre-existing conventions

  • Attributes: interface, _internal, __private

I grew up on Java, which took Small Talk's camel case convention, so I'm just wondering: what's wrong with camel case anyway? The "blessed" coding convention in Python is the one thing I don't quite get. Is there an argument for underscores?

I swear I am not trying to start a flame war. It's just that I'm wondering if the preference is completely arbitrary or not.

8

u/fireflash38 Jun 23 '14

Pretty sure most preferences with this are kind of arbitrary. I think the idea is to make it similar to natural language with _ in lieu of a space.