On 24Jul2019 07:21, DL Neil <pythonl...@danceswithmice.info> wrote:
Accordingly, the idea that there would be a ClassyThing() but it might be quite different from another ClassyThing() just makes me shudder!
(sorry, I guess it's that sheltered upbringing ... again!)

It needn't be very different on the outside. The whole point of object oriented programme is to present things with the same external API but different internal implementations, or managing a different thing with common characteristics.

I have use nested classes when the nested class is strongly associated with the enclosing class, like your classname.exceptionname example. I'd put it inside the outer class entirely to express that association.

...and, because the (?old) boy can't be relied upon to remember to import both, nesting saves-the-day!

Get some linting tools. They're great for catching this kind of error.

The tricky bit with dynamic language like Python is that some naming errors (missed imports) aren't apparent until the code passes through that path. Linters can cover a lot of this with static analysis.

Cheers,
Cameron Simpson <c...@cskk.id.au>
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to