Import redirects

Chris Angelico rosuav at gmail.com
Mon Feb 11 02:32:51 EST 2013


On Mon, Feb 11, 2013 at 6:28 PM, Mark Lawrence <breamoreboy at 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



More information about the Python-list mailing list