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

So which is better and why?

def my_function():

or

def myFunction():

This question is related to python naming-conventions pep8

The answer is


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


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.


Examples related to python

programming a servo thru a barometer Is there a way to view two blocks of code from the same file simultaneously in Sublime Text? python variable NameError Why my regexp for hyphenated words doesn't work? Comparing a variable with a string python not working when redirecting from bash script is it possible to add colors to python output? Get Public URL for File - Google Cloud Storage - App Engine (Python) Real time face detection OpenCV, Python xlrd.biffh.XLRDError: Excel xlsx file; not supported Could not load dynamic library 'cudart64_101.dll' on tensorflow CPU-only installation

Examples related to naming-conventions

How to name Dockerfiles What is the difference between .yaml and .yml extension? Is there a naming convention for git repositories? What's the name for hyphen-separated case? Should I use "camel case" or underscores in python? Is there a naming convention for MySQL? What is the javascript filename naming convention? REST URI convention - Singular or plural name of resource while creating it What is the standard naming convention for html/css ids and classes? What are naming conventions for MongoDB?

Examples related to pep8

what is trailing whitespace and how can I handle this? How do I set the maximum line length in PyCharm? What is PEP8's E128: continuation line under-indented for visual indent? Should I use "camel case" or underscores in python? Python `if x is not None` or `if not x is None`? Pylint, PyChecker or PyFlakes? Why does PEP-8 specify a maximum line length of 79 characters?