Python Forum
how to pass data between modules while importing
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to pass data between modules while importing
#1
i have 2 modules that are somewhat related. they both get imported in sequence, usually with nothing between being imported, by the script that needs them. is there a way for the 1st one to leave some data for the 2nd one? they will know each other's name, but having one of them import the other is not an option (because of cases where one one of them is to be imported).
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
Skaperen Wrote:is there a way for the 1st one to leave some data for the 2nd one?
What does it mean? If mod2 needs data from mod1, then why doesn't mod2 import mod1? It looks like a wrong design that needs to be fixed.
Reply
#3
both modules need to be imported like from modname import *. in some cases they can interfere. but if the data is passed on, the 2nd one can avoid that.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#4
The modules need to be imported that way because that's how you have designed your program, which does not negate the point made by Gribouillis.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#5
so i should assume there is no way to do that.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#6
It is very difficult to understand what you want to do. Why don't you just post the modules?
Reply
#7
(Nov-24-2019, 09:58 PM)Gribouillis Wrote: It is very difficult to understand what you want to do. Why don't you just post the modules?

as is very often the case, code is, at minimum, not complete. in this case, things are not integrated and there is no point in coding that unless the solution is known.
Tradition is peer pressure from dead people

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


Forum Jump:

User Panel Messages

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