split python source code into multiple files?

后端 未结 4 1657
轮回少年
轮回少年 2021-01-30 08:02

I have a code that I wish to split apart into multiple files. In matlab one can simply call a .m file, and as long as it is not defined as anything in particular it

4条回答
  •  没有蜡笔的小新
    2021-01-30 08:53

    Python has importing and namespacing, which are good. In Python you can import into the current namespace, like:

    >>> from test import disp
    >>> disp('World!')
    

    Or with a namespace:

    >>> import test
    >>> test.disp('World!')
    

提交回复
热议问题