Pythonic way to name derived classes?

Use common sense. In your example, as others have discussed, the Fruit part is obviously redundant. Use just Apple, Orange, etc.Let's consider use another example instead.

If I had a base class called Plugin, I would name the derived class FormattingPlugin, which I read as “plugin that does formatting�. The alternative, PluginFormatting, reads as “formatting of plugins�. I guess the reading is subjective, so use your own best judgment.

But don't name it just Formatting, because, unlike in the fruits example, that's not a complete enough description of what the class does.

1 very good example! – delnan Nov 24 at 18:34.

Concensus" is an elusive concept. What you can do though is look to naming conventions used in the standard library to get a sense of what is the norm within the Python community. For example, here's one extensive list of related classes and subclasses: docs.python.org/library/internet.html In the end though, it is a matter of taste guided by the principle that class names which are the clearest to the user are the best names.

In the specific example you list above, everyone knows these things are fruits, so I think it is unnecessary to include Fruit in the subclass names. More generally, whatever you chose is fine as long as it is consistent. I tend to like the French way of naming the object first and descriptors (adjectives) afterwards, so if I had to choose, I would prefer FruitApple, FruitOrange, etc.Over AppleFruit, OrangeFruit (and the redundant PassionFruitFruit :)).

It also has the advantage of showing all the subclasses in a cluster when listed alphabetically, which might help some IDEs or code completers. If, on the other hand, you take the standard library as the model, you'll find a preference for naming subclasses in SpecificBase format. For example, the logging module defines StreamHandler and FileHandler as subclasses of Handler.

2 The flip side of showing all the subclasses is that you have to type more until the name is unique and you can tab-complete it. – Petr Viktorin Nov 24 at 17:51.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions