Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

do you see CamelCase much in Python methods and functions?

The PEP 8 style guide (Python) says methodnames should be lowercase and that sometimes method_names may have embedded underscores. Do experienced Python programmers often come across CamelCase (with leading capital) methods?

like image 385
H2ONaCl Avatar asked Dec 13 '22 17:12

H2ONaCl


1 Answers

In my experience, a module's naming conventions depends on the following factors:

  • If it's a newly written, Python-only module, or if the authors especially care for "Pythonic code" (quite common!), the naming usually sticks to the recommendations in the Python Style Guide.
  • Beginners to Python often stick to their favorite style, especially if they have a Java/C#/... background.
  • Some companies prefer a consistent naming style across languages.
  • Some Python modules adapt an API from other languages (especially Java in the threading and xml.dom modules), including naming style.
  • Python bindings for C/C++ libraries usually keep the original naming (e.g. camelCase for PyQt or PascalCase for VTK)

I think the last point is the most common way that you will find PascalCase in Python code.

like image 138
Ferdinand Beyer Avatar answered Dec 28 '22 23:12

Ferdinand Beyer