Skip to main content
Post Reopened by Adrian Mole, TheMaster, Rich
Post Closed as "Opinion-based" by Karl Knechtel, MisterMiyagi, cigien
deleted 8 characters in body; edited tags; edited title
Source Link
cobrexus
  • 4.9k
  • 5
  • 24
  • 53

What is the naming convention in Python for variablevariables and functionfunctions?

Coming from a C# background the naming convention for variables and method namesmethods are usually either camelCase or PascalCase:

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

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

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

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

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

Coming from a C# background the naming convention for variables and method names are usually either camelCase or PascalCase:

// 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?

What is the naming convention in Python for variables and functions?

Coming from a C# background the naming convention for variables and methods are usually either camelCase or PascalCase:

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

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

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

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

edited tags
Link
Super Kai - Kazuya Ito
  • 42.8k
  • 23
  • 258
  • 257
edited tags
Link
Karl Knechtel
  • 61.4k
  • 14
  • 133
  • 193
edited tags; edited title
Link
Super Kai - Kazuya Ito
  • 42.8k
  • 23
  • 258
  • 257
Loading
fixed indentation
Source Link
Georgy
  • 14k
  • 7
  • 69
  • 80
Loading
Question Protected by Robert Harvey
edited tags
Link
SilentGhost
  • 322.1k
  • 67
  • 312
  • 294
Loading
Source Link
Ray
  • 193.7k
  • 99
  • 229
  • 206
Loading