group several methods under a attribute
Aahz
aahz at pythoncraft.com
Thu Apr 9 09:06:17 EDT 2009
In article <mailman.3435.1239058603.11746.python-list at python.org>,
Rhodri James <rhodri at wildebst.demon.co.uk> wrote:
>
>You'll note that this is, all Aaron's protests to the contrary,
>splitting your class up into multiple cooperating classes.
Ayup.
>If you're set on doing it like this, doing it this way avoids polluting
>your namespace so much:
>
>class ClsB(object):
> class ClsA(object):
> def do_something(self):
> print "Here's A doing something"
>
> def __init__(self):
> self.A = ClsB.ClsA()
>
> def do_something(self):
> print "Here's B doing something"
Blech. The pollution caused by a separate class is minimal, and nested
class definitions are likely to have problems (the most obvious is that
pickling will break).
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
Why is this newsgroup different from all other newsgroups?
More information about the Python-list
mailing list