Python Forum
selecting a module at run time
Thread Rating:
  • 2 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
selecting a module at run time
#1
i am working on some new scripts to handle openvpn tunnels. there will be commands to start and stop particular ends of a tunnel in listen/server mode or connect/client mode. i want to have the configuration of a whole tunnel (both ends) in a single python modules. all of these modules will be in a particular directory. i could then write commands to do things with groups of tunnels or with all tunnels such as "tun-cmd server all start".
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
Maybe importlib can help you.

import importlib

my_module = 'os'
m = importlib.import_module(my_module)

print(m.getenv("PATH"))
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Problem with module time and leap seconds Pedroski55 3 1,237 Oct-07-2022, 11:27 PM
Last Post: Pedroski55
  Module 'time' has no attribute 'clock' Sophie 4 3,103 Jan-25-2022, 08:05 PM
Last Post: Sophie
  Installing time module Led_Zeppelin 2 11,877 Aug-31-2021, 02:16 PM
Last Post: Led_Zeppelin
  finding yesterday and tomorrrow without using date.time module apexman 10 5,513 Feb-25-2019, 05:33 AM
Last Post: samsonite
  Time module help YevesDraco 3 3,705 May-07-2017, 04:17 PM
Last Post: YevesDraco

Forum Jump:

User Panel Messages

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