如何从另一个文件打印变量

How to print variable from another file

在下面的代码中,我从 Interactive 收到了 XAUUSD 的头寸 经纪人。有人能告诉我如何在另一个 python 文件中捕获变量 maypos 的更新值吗?

from ib.opt import Connection, message
from ib.ext.Contract import Contract
from ib.ext.Order import Order
import time
import os
import datetime
import random


def error_handler(msg):
    print ("Server Error: %s" % msg)
    return


def replies_handler(msg):
    print ("Server Response: %s, %s" % (msg.typeName, msg))
    return


def print_portfolio_position(msg):

    if msg.contract.m_symbol == "XAUUSD":
       mypos = msg.position
       print("Position:", msg.contract.m_symbol, msg.position, 
               msg.marketPrice, msg.contract.m_currency, msg.contract.m_secType)


if __name__ == "__main__":

    while 1:


        time.sleep(5)
        conn = Connection.create(port=4096, clientId=1)
        conn.connect()
        conn.register(error_handler, 'Error')
        conn.register(print_portfolio_position, 'UpdatePortfolio')
        conn.register(replies_handler, 'UpdateAccountValue')
        conn.reqAccountUpdates(1, '')
        time.sleep(2)
        conn.disconnect()

Question: how can I catch updated value of the variable maypos in another python file?

from another python file import maypos

value = maypos.updated value