Python Forum
informatio from importer to importee
Thread Rating:
  • 2 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
informatio from importer to importee
#1
i have a module that defines some functions that aid debugging. it checks an environment variable. if that environment variable is defined, it defines the functions to do their thing, which for most involves printing. if that environment variable is not defined then the functions are defined to do nothing and return so that the script can be run without any debugging output to easily see if the output is correct.

what i would like to have is a way for the code doing the importing to specify which environment variable is to be checked when it does the check to determine what it will define. however, since the debugging module comes from a different file, it does not share either global or local namespaces with the code doing the importing. that means this will not be as simple as setting a global variable and checking it. i also would like to have a way for the script to force the debugging functions to be enabled regardless of any environment variable.

the workaround idea i have it to set another environment variable in the script before it imports the module, and have the module check this other environment variable to get the name to use.

so my questions are: how safe is this? what kinds of issues do you see in this? is there a better alternative?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
informatio from importer to importee - by Skaperen - Nov-18-2018, 07:31 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Custom importer and errors Fips 6 617 Apr-14-2024, 02:34 PM
Last Post: Pedroski55

Forum Jump:

User Panel Messages

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