How to extend inner classes?

Discussion in 'Python' started by Kay Schluehr, Nov 28, 2004.

  1. Kay Schluehr

    Kay Schluehr Guest

    >>/ 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()
    />>/ <__main__.Pos instance at 0x00EEFAD0>
    /
    > 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.


    > Alex


    *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
    Kay Schluehr, Nov 28, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Carlo v. Dango
    Replies:
    14
    Views:
    1,010
    Alex Martelli
    Oct 19, 2003
  2. Replies:
    0
    Views:
    315
  3. Kay Schluehr

    How to extend inner classes?

    Kay Schluehr, Nov 27, 2004, in forum: Python
    Replies:
    1
    Views:
    330
    Alex Martelli
    Nov 28, 2004
  4. harold fellermann

    How to extend inner classes?

    harold fellermann, Dec 21, 2004, in forum: Python
    Replies:
    0
    Views:
    349
    harold fellermann
    Dec 21, 2004
  5. Juha Nieminen
    Replies:
    9
    Views:
    911
    Kai-Uwe Bux
    Jun 13, 2011
Loading...

Share This Page