Python Forum
modifying what a module defines
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
modifying what a module defines
#3
(Aug-22-2019, 10:02 PM)Skaperen Wrote: i have a module that defines some classes and functions. i want to also include some debug tools in it as well. my goal is to get everything in one file. but i don't want the debug tools to be defined every time the module is imported. i'd like to have a way that the code that is importing this module can indicate if it wants the debug tools, too. is there any way to do this within Python3? i'm looking for alternatives to setting (in the code doing the import) and getting (in the module) an environment variable. any suggestions?

Hi!

Not sure if I could help you, as it seems that with so many posts, you probably know much more than I do...

I'm learning and I was following the instructions to build a calculator, so I needed to import a module called something like calc_functions.py, but while I was learning how to build the calculator, I needed to define some functions to work with the function keys on the calculator, as a factorials key, a number base 10 to Roman numbers key, or a number base 10 to binary key, but it was not working as the calc_functions file had everything already done there, so I made another file, that I called myCalc_functions.py and defined there my functions. Of course, I had to call this new file, instead of the other one, to be able to work. Even now, I created a myCalc_functions_02.py where I change a very long tuple and dictionary into a tuple of tuples.

Okay, what I mean is, if you haven't a better way, couldn't you just have 2 modules files that you could import, one with the debug tools and another one without them, and choose to import one or the other file at the beginning of the program and made the necessary modifications?

Well, it was just a thought...

All the best,
newbieAuggie2019

"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs
Reply


Messages In This Thread
modifying what a module defines - by Skaperen - Aug-22-2019, 10:02 PM
RE: modifying what a module defines - by fishhook - Aug-23-2019, 06:39 AM
RE: modifying what a module defines - by newbieAuggie2019 - Aug-23-2019, 11:01 AM
RE: modifying what a module defines - by Skaperen - Aug-24-2019, 07:26 PM
RE: modifying what a module defines - by fishhook - Aug-26-2019, 06:29 AM
RE: modifying what a module defines - by Skaperen - Aug-26-2019, 07:34 PM
RE: modifying what a module defines - by Skaperen - Aug-28-2019, 07:34 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  input defines variable but it's not defined tozqo 5 7,363 Jun-05-2017, 02:45 AM
Last Post: tozqo

Forum Jump:

User Panel Messages

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