PEP: import version

Andrew Bennetts andrew-pythonlist at puzzling.org
Thu May 13 04:07:27 EDT 2004


On Thu, May 13, 2004 at 07:46:51AM +0000, Manlio Perillo wrote:
[...]
> A possible syntax is this:
> import wxPython version '2.4'

I'd like to see versioned imports too, but it looks like a tricky problem to
me.  Some questions that immediately spring to mind reading your proposal:

How would this work with from X import Y?  How would this work with packages
(e.g. import X.Y.Z)?

e.g. how would you add version requirements to these statements:

    from gtk import main

    from twisted.web import server

For the first one, "from gtk version '2.0' import main" doesn't look too
bad.

But what about the second one -- can only top-level modules/packages have
versions?  e.g. what if the "twisted.web" package has a version that's
independent of the top-level "twisted" container package?  Would "from
twisted.web version '1.3.0'" mean Twisted version 1.3.0, or Twisted Web
version 1.3.0?

What happens if the same program tries to import different (and possibly
conflicting) versions of the same module, e.g.:

    import gtk version '2.0'
    import gtk version '1.2'

Should an ImportError be raised?  Should it succeed (assuming both versions
are available)?  Is it even possible to have two different versions of the
same library/module installed in parallel, and if so, how?

I'd love to see a proposal that addresses all of these points :)

> Another case is when the module is implemented also in C:
> import picke version 'C'

Alternative implementations of the same module for reasons of optimisation
is a different problem, and I don't think it's a good idea to try solve it
the same way.

-Andrew.





More information about the Python-list mailing list