Is it a good idea to define a class within a class in Python?

Posted by rmh on Stack Overflow See other posts from Stack Overflow or by rmh
Published on 2010-05-03T23:52:57Z Indexed on 2010/05/03 23:58 UTC
Read the original article Hit count: 188

Filed under:

I've sometimes seen code like this:

class Something(object):

    class Else(object):

        def __init__(self):
            pass

    def __init__(self):
        # Do something with self.Else...
        pass

Is it a good idea to define classes inside related classes? Is this an acceptable way to group related code?

© Stack Overflow or respective owner

Related posts about python