Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #38653

Re: Import redirects

References <CAOArY3VQFytYUZrKxxRHOYQfxP85=P6yT5b83wzpJBMwK4hKGQ@mail.gmail.com> <kfa6if$crn$1@ger.gmane.org>
Date 2013-02-11 18:32 +1100
Subject Re: Import redirects
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1631.1360567980.2939.python-list@python.org> (permalink)

Show all headers | View raw


On Mon, Feb 11, 2013 at 6:28 PM, Mark Lawrence <breamoreboy@yahoo.co.uk> wrote:
> On 11/02/2013 06:50, Isaac To wrote:
>>
>> I have a package (say "foo") that I want to rename (say, to "bar"), and
>> for compatibility reasons I want to be able to use the old package name
>> to refer to the new package.
>
>
> My apologies for the over engineering, but this is the best I could come up
> with.
>
> import bar as foo

That puts it into sys.modules as bar, though; you'd need to change the
import in every place it's used. If that's acceptable, great, but my
reading of the OP was that the goal was to let other scripts import
foo and get bar.

ChrisA

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Import redirects Chris Angelico <rosuav@gmail.com> - 2013-02-11 18:32 +1100

csiph-web