Rayme Jernigan wrote:

I'm looking for a language to abuse for a project I'm working on. I
know a little Python, but I do not know if it can do this: I'd like to
define some class "N" that instantiates objects that can instantiate
fresh new objects of that same class... without external controller
code.

This the sort of thing you mean?

class _Base:
        def __call__(self, *args, **kargs):
                return self.__class__(*args, **kargs)

class Foo(_Base):
        pass

class Bar(_Base):
        pass

f = Foo()
b = Bar()
print f, f()
print b, b()

HTH

has
--
http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Reply via email to