[Python-3000] Discussions with no PEPs

Nick Coghlan ncoghlan at gmail.com
Tue Mar 13 23:37:13 CET 2007


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.

This is why the idea of lazy importing comes up pretty fast whenever 
generics are discussed.

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

Regards,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org


More information about the Python-3000 mailing list