"my brain hurts" or is isinstance broken?

Greg Ewing see_reply_address at something.invalid
Thu Jul 4 20:47:14 EDT 2002


robert_kuzelj at yahoo.com:

> 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()


I would split the register method into two methods,
register_factory and register_prototype. That would
put the responsibility on whatever registers the
object to know what kind of thing it is.

-- 
Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg




More information about the Python-list mailing list