How to extend inner classes?

K

Kay Schluehr

/ You can define a class variable Pos with the class Pos as its value
/>>/
/>>/ class PeriodicGrid :
/>>/ class Pos:
/>>/ pass
/>>/ Pos = Pos
/>>/
/>>/ >>> grid = PeriodicGrid()
/>>/ >>> grid.Pos()
/>>/ said:
You can, but that 'Pos = Pos' statement in this code is just as
redundant and useless as it appears. In every aspect, the behavior will
be exactly identical if you remove that assignment.

*sigh*

It's a matter of good i.e. bad taste. Ususally I prefer constructs like this:

class Pos:
class Pos:
def __init__(self):
self.__dict__ = Pos.__dict__
Pos = staticmethod(Pos)

and spread them all over my code thinking they are genuine Pythonic
with the emphasis of the original meaning of the word and for sake of the
great ancestors. I call them "strange idiom" idioms and they are
made for torturing mankind. If a believing christ would ask me why i do so
the answer would be: calling the animal and accelerating judgement day.

Bye and have a nice Sunday afternoon

Kay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,800
Messages
2,569,656
Members
45,395
Latest member
ErinStLeon
Top