Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Chaining scripts
#2
Yes, you can have a common module that contains the data shared by other parts of your app (or provides access to such data). Other modules import the common module. For example
# common.py

class SharedState:
    def __init__(self):
        self.foo = 14

state = SharedState()



# module sensors.py

from common import state

def bar():
    print(state.foo + 1)


# module mcp3008.py

from common import state
qux = state.foo ** 2
print('etc')
Reply


Messages In This Thread
Chaining scripts - by Steffenwolt - Jan-15-2018, 09:30 PM
RE: Chaining scripts - by Gribouillis - Jan-15-2018, 10:23 PM
RE: Chaining scripts - by Steffenwolt - Jan-16-2018, 09:25 AM
RE: Chaining scripts - by Gribouillis - Jan-16-2018, 09:34 AM

Forum Jump:

User Panel Messages

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