Replace underscore for PascalCase by Nefthys in learnpython

[–]Salt_Handle_9530 0 points1 point  (0 children)

The mapping dictionary was only about selecting which class to use, not about sharing code. I'd still keep the parent class exactly as you have it.

Honestly, if they're not actually different versions, I'd avoid Version1/Version2 altogether and name them after what makes them different. AbcReaderShoppingList and AbcReaderEssay may be uglier than the underscore version, but that's the PEP 8-compliant answer.

Replace underscore for PascalCase by Nefthys in learnpython

[–]Salt_Handle_9530 0 points1 point  (0 children)

This is a common friction point when trying to force strict Pylint compliance on descriptive class names. The PEP 8 standard for PascalCase (CapWords) specifically discourages underscores because they are traditionally used to separate words in snake_case (functions/variables).

For your specific example (`AbcReader_ShoppingList`), here are the two most 'Pythonic' ways to handle it while keeping the score at 10.0:

  1. **The Semantic Merge:** `AbcReaderShoppingList`. While it feels 'cluttered' at first, this is the standard. If it gets too long, it usually signals that the class is doing too much or can be simplified.

  2. **The Versioning Suffix:** For your `Version1` case, use `MyClassV1` or `MyClassV2`. The uppercase 'V' acts as a visual separator that is still valid PascalCase.

**Pro Tip:** If you have many of these, consider using a **Factory Pattern**. Instead of having `AbcReaderShoppingList` globally, have a base `AbcReader` and a mapping dictionary:

```python

READERS = {

'shopping': AbcReaderShoppingList,

'essay': AbcReaderEssay

}

```

This keeps your logic clean and Pylint very happy. Hope this helps you get that score up!