Should I use "camel case" or underscores in python?

283

So which is better and why?

def my_function():

or

def myFunction():

This question is tagged with python naming-conventions pep8

~ Asked on 2012-01-18 10:45:05

The Best Answer is


296

for everything related to Python's style guide: i'd recommend you read PEP8.

To answer your question:

Function names should be lowercase, with words separated by underscores as necessary to improve readability.

~ Answered on 2012-01-18 10:48:15


35

PEP 8 advises the first form for readability. You can find it here.

Function names should be lowercase, with words separated by underscores as necessary to improve readability.

~ Answered on 2012-01-18 10:47:21


Most Viewed Questions: