Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8547617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:18:15+00:00 2026-06-11T13:18:15+00:00

I want to do some package import timing tests. For this, I want to

  • 0

I want to do some package import timing tests. For this, I want to define a list of packages:

packages = [ 'random', 'dateutils', ... ]

for package in packages:
    import package

This is of course not working because import tries to import package “package”. How can I tell import to import the package pointed to by the variable “package”?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T13:18:16+00:00Added an answer on June 11, 2026 at 1:18 pm
    for package in packages:
        package = __import__(package)
    

    Note that if you are importing a module from a package, such as A.B,

    __import__('A.B') returns package A, but __import__('A.B', fromlist = [True]) returns module B.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I'm not online, I sometimes want to package some changes to a commit,
I want to import some package depending on which value the user chooses. The
I want to build some package from source ( e2fsprogs to be more concrete)
I want to make a component that uses some resources compiled in my package's
I want some examples of C preprocessor directives, such as: #define pi 3.14 #define
I want some like this: How make it ideologically correct?
I have tried to do this here http://wonderfl.net/c/9Kdv but what I want is not
I'm tring to create an SSIS package to import some dataset files, however given
This dialog asks whether you want to install some other app...so when onclicked no
I want to package some UIViews suchs as UIButton, UIImageView in a single UIView.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.