That is just a convoluted way to set a global.
m
is a class, m.result
a class attribute. Both the sender and receiver can access it directly, just as they can access m
.
They could have done this too:
# sender
import message
message.result = someCalculationResult
# receiver
import message
print message.result
Here result
is just a name in the message
module top-level module.
It should be noted that what you are doing is not running separate scripts; you are importing modules into the same interpreter. If you ran python sender.py
first, without ever importing reciever.py
, then separately running python receiver.py
without ever importing sender.py
this whole scheme doesn't work.
There are myriad ways to pass data from one section of code to another section, too many to name here, all fitting for a different scenario and need. Threading, separate processes, separate computers all introduce different constraints on how message passing can and should take place, for example.