Python Forum
How to assign a module to a variable even if it's not defined?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to assign a module to a variable even if it's not defined?
#2
This looks very much like XY problem. Would you elaborate on what the ultimate goal is? "check if the modules python files exist or not" is not very clear.

e.g. if you want to check that trying to import module will not raise error - there is idiomatic way to do it using try/except

if you want to import module by using name string - look at importlib
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
RE: How to assign a module to a variable even if it's not defined? - by buran - Aug-12-2020, 02:16 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Variable not defined even though it is CoderMerv 3 348 Mar-28-2024, 02:13 PM
Last Post: Larz60+
  Variable is not defined error when trying to use my custom function code fnafgamer239 4 630 Nov-23-2023, 02:53 PM
Last Post: rob101
  Printing the variable from defined function jws 7 1,395 Sep-03-2023, 03:22 PM
Last Post: deanhystad
  [variable] is not defined error arises despite variable being defined TheTypicalDoge 4 2,183 Apr-05-2022, 04:55 AM
Last Post: deanhystad
  Error when refering to class defined in 'main' in an imported module HeRo 2 2,434 Apr-13-2021, 07:22 PM
Last Post: HeRo
  When I print a key from dict it prints it but when I try to assign it to a variable I stefanvelikov 3 2,389 Nov-27-2020, 01:29 PM
Last Post: stefanvelikov
  Function will not return variable that I think is defined Oldman45 6 3,575 Aug-18-2020, 08:50 PM
Last Post: deanhystad
  Variable not defined Heyjoe 4 2,606 Jul-10-2020, 11:27 PM
Last Post: Heyjoe
  python library not defined in user defined function johnEmScott 2 3,909 May-30-2020, 04:14 AM
Last Post: DT2000
  Error: variable can not be defined julio2000 2 3,227 Feb-09-2020, 08:51 PM
Last Post: julio2000

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020