What is the naming convention in Python for variable and function names?

Posted by Ray Vega on Stack Overflow See other posts from Stack Overflow or by Ray Vega
Published on 2008-10-01T21:01:16Z Indexed on 2010/04/25 11:33 UTC
Read the original article Hit count: 260

Coming from a C# background the naming convention for variables and method names are usually either CamelCase or Pascal Case:

// C# example
string thisIsMyVariable = "a"
public void ThisIsMyMethod()

In Python, I have seen the above but I have also seen underscores being used:

# python example
this_is_my_variable = 'a'
def this_is_my_function():

Is there a more preferable, definitive coding style for Python?

© Stack Overflow or respective owner

Related posts about python

Related posts about functions