Classes as objects
Just van Rossum
just at letterror.com
Fri Apr 27 03:44:45 EDT 2001
"Daniel Klein" <DanielK at jBASE.com> wrote:
> Haven't posted for a while but I this time I am requesting some assistence.
>
> I'm putting on a presentation on the benefits of Python over Java and one of
> the points I would like to make is how everything is an object, even
> Classes. Can anyone out there in PythonVille provide a simple (practical)
> example of how classes can be used as objects?
Ken Seehof wrote:
> Here's a debugging hack that messes with classes:
[ ... ]
While I agree it's useful to mess with this stuff for debugging, but you
don't need to go that for for classes to be useful as objects: classes can
be seen as factory functions, and passed around as such, eg:
class Foo:
helperFactory = HelperClass
def __init__(self, arg):
self.helper = self.helperFactory(arg)
class Boo(Foo):
helperFactory = OtherHelperClass
Just
More information about the Python-list
mailing list