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

PythonNaming ConventionsPep8

Python Problem Overview


So which is better and why?

def my_function():

or

def myFunction():

Python Solutions


Solution 1 - Python

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.

Solution 2 - Python

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.

Solution 3 - Python

> 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

Check out its already been answered, click here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiontdcView Question on Stackoverflow
Solution 1 - PythonaayoubiView Answer on Stackoverflow
Solution 2 - PythonDavid MView Answer on Stackoverflow
Solution 3 - PythonHarish KurupView Answer on Stackoverflow