Re: Import redirects

Discussion in 'Python' started by Chris Angelico, Feb 11, 2013.

  1. On Mon, Feb 11, 2013 at 6:28 PM, Mark Lawrence <> 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
    Chris Angelico, Feb 11, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark
    Replies:
    0
    Views:
    296
  2. Isaac To

    Import redirects

    Isaac To, Feb 11, 2013, in forum: Python
    Replies:
    0
    Views:
    105
    Isaac To
    Feb 11, 2013
  3. Mark Lawrence

    Re: Import redirects

    Mark Lawrence, Feb 11, 2013, in forum: Python
    Replies:
    0
    Views:
    97
    Mark Lawrence
    Feb 11, 2013
  4. Oscar Benjamin

    Re: Import redirects

    Oscar Benjamin, Feb 11, 2013, in forum: Python
    Replies:
    0
    Views:
    110
    Oscar Benjamin
    Feb 11, 2013
  5. Isaac To

    Re: Import redirects

    Isaac To, Feb 12, 2013, in forum: Python
    Replies:
    0
    Views:
    81
    Isaac To
    Feb 12, 2013
Loading...

Share This Page