Python 的軟體工程原則
Adam Spannbauer
Machine Learning Engineer at Eastman

正在 work_dir/my_package/utils.py 作業
def we_need_to_talk(break_up=False):
"""Helper for communicating with significant other"""
if break_up:
print("It's not you, it's me...")
else:
print('I <3 U!')
正在 work_dir/my_script.py 作業
# Import utils submodule
import my_package.utils
# Decide to start seeing other people
my_package.utils.we_need_to_talk(break_up=True)
It's not you, it's me...
正在 work_dir/my_package/__init__.py 作業
from .utils import we_need_to_talk
正在 work_dir/my_script.py 作業
# Import custom package
import my_package
# Realize you're with your soulmate
my_package.we_need_to_talk(break_up=False)
I <3 U!


Python 的軟體工程原則