doing non-prespecified imports

Discussion in 'Python' started by Jon Perez, Jul 31, 2004.

  1. Jon Perez

    Jon Perez Guest

    Is it possible to do:

    import xxxx

    within code where xxxx is specified by
    a string or user input?


    I need this in order to be able to load different,
    arbitrary modules under application-user control.

    If not using the 'import xxxx' syntax, is there
    a roundabout way to do such?
    Jon Perez, Jul 31, 2004
    #1
    1. Advertising

  2. On Sat, Jul 31, 2004 at 08:32:14AM +0800, Jon Perez wrote:
    > Is it possible to do:
    >
    > import xxxx
    >
    > within code where xxxx is specified by
    > a string or user input?
    >
    >
    > I need this in order to be able to load different,
    > arbitrary modules under application-user control.
    >

    See the built-in function __import__()
    egbert
    --
    Egbert Bouwman - Keizersgracht 197 II - 1016 DS Amsterdam - 020 6257991
    ========================================================================
    Egbert Bouwman, Jul 31, 2004
    #2
    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. Replies:
    2
    Views:
    441
    Ira Baxter
    Dec 20, 2005
  2. Albert
    Replies:
    4
    Views:
    10,871
    Albert
    Jul 10, 2008
  3. Replies:
    5
    Views:
    266
  4. zildjohn01
    Replies:
    0
    Views:
    648
    zildjohn01
    Feb 22, 2011
  5. Victor Hooi
    Replies:
    1
    Views:
    106
    Devin Jeanpierre
    Nov 25, 2013
Loading...

Share This Page