"my brain hurts" or is isinstance broken?
Robert Kuzelj
robert_kuzelj at yahoo.com
Wed Jul 3 09:55:18 EDT 2002
hi jonathan,
> Pretty much *everything* in the system is an object. This makes the entire
> language uniform in its operation. It makes instrospection easier and it
> allows metaclasses to change the behaviour of classes.
i know that and i like it.
> Then perhaps you could explain your problem and maybe we can help. So far
> you've told us how you're going about something, but not why.
>
> Why do you need to differentiate between classes and "instances"? Perhaps
> there's another way to do what you want that will work.
lets simply say: the requirement is exactly to destinguish between
instances and classes.
one could imagine an object that is a mix between a factory and
a prototyperegistry.
class ProtoFactory:
def __init__(self):
self.SourceObjects = {}
def register(self, name, source):
self.SourceObjects[name] = source
def create(self, name):
source = self.SourceObjects(name)
if isinstance(source, types.Instance.Type):
return copy.copy(source)
else:
return source()
this is just an example. i am sure, that this can be done
differently. the real reason why i want to do this is something
i realy dare not to say in this forum ;-)
just that i am realy realy nasty!
ciao robertj
>
> Jonathan
More information about the Python-list
mailing list