A code reviewer notices that a Python module defines a class named `dataProcessor` and a function named `processData`. The team follows PEP 8. Which naming convention should be applied to the class name?
PEP 8 states that class names should normally use the CapWords convention (also known as PascalCase), where each word starts with an uppercase letter and there are no underscores. Renaming `dataProcessor` to `DataProcessor` aligns with this widely accepted standard, improving readability and consistency across Python codebases. This is the correct convention for classes.
Why this answer
PEP 8 recommends CapWords (PascalCase) for class names, so `DataProcessor` is the correct choice. Snake_case, camelCase, and all-uppercase with underscores are used for other purposes: functions/variables, non-standard style, and constants respectively. Adhering to this convention ensures consistency and readability in Python projects.
Exam trap
The trap here is assuming that any consistent naming style is acceptable, but PEP 8 specifically mandates CapWords for classes.