At 08:37 AM 3/14/2007 +1000, Nick Coghlan wrote: >Greg Ewing wrote: > > Nick Coghlan wrote: > > > >> Generics can live quite happily inside modules and as methods on objects. > > > > If instead of pydoc it's some third party module, > > the situation is even worse, since the module may > > not even be installed on the user's system. > > > > So this scheme would seem to create undesirable > > dependencies.
In cases where you don't already have such a dependency, yeah. >This is why the idea of lazy importing comes up pretty fast whenever >generics are discussed. I call 'em "weak" imports, myself: http://peak.telecommunity.com/DevCenter/Importing#weak-imports As it happens, you need the same thing for adaptation, which is why I put this into PEAK way back in the heydey of Python 2.2. >However, this criticism regarding importing otherwise unneeded modules >also applies to interfaces and ABC's, only more so. For example, if I >wanted to declare that a class implements (or inherits from) >pydoc.IDocumentable, then I would have to import pydoc first, and as I >need to do it at class definition time (assuming we're using the normal >inheritance mechanism to declare our interfaces), lazy importing can't help. > >3rd-party registration of 'A implements I' or 'here's how to convert A >to something that implements I' is useful not only for adapting two >libraries to play well together, but also in allowing the libraries >themselves to delay these definitions until they're known to be at least >potentially neeeded (e.g. don't register a class as being documentable >until the application actually imports and starts using pydoc). An excellent point, indeed. _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com