Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

197
Views
¿Cómo hacer desde la importación del módulo * usando importlib?

Me gustaría lograr el mismo resultado que from module import * usando importlib.

Esta pregunta Importar módulo con un nombre local usando importlib describe cómo import module as mod , que está relacionado pero no es lo mismo.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Para emular from X import * debe importar el módulo y luego fusionar los nombres apropiados en el espacio de nombres global.

 # get a handle on the module mdl = importlib.import_module('X') # is there an __all__? if so respect it if "__all__" in mdl.__dict__: names = mdl.__dict__["__all__"] else: # otherwise we import all names that don't begin with _ names = [x for x in mdl.__dict__ if not x.startswith("_")] # now drag them in globals().update({k: getattr(mdl, k) for k in names})
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!