I am using Python for automating a complex procedure that has few options. I want to have the following structure in python. - One "flow-class" containing the flow - One helper class that contains a lot of "black boxes" (functions that do not often get changed).
99%的时间里,我修改了流层中的物品,因此我只想制定时常加以修改的代码,这样我就不必在一片土地上开车,以找到我想修改的法典。 这一类别还包含经常发生变化的全球变量(组合环境)。 助手类别包含全球变量,但往往没有变化。
In the flow-class I have a global variable that I want the user to be forced to input at every run. The line looks like this. print ("Would you like to see debug output (enter = no)? ") debug = getUserInput()
自动交换机功能应当位于助手类别,因为它从未修改过。 获取用户数据需要流量类别产生的全球变量,这表明用户投入是否应当与六氯环己烷的指挥线或Eclipse(在Windows上运行)。
My question is: How can I structure this in the best way? Currently it looks like the following: The flow-class:
import helper_class
isLinux = 1
debug = getUserInput()
助手:
import os, flow_class
def getUserInput():
userInput = input ()
if (flow_class.isLinux == 1):
userInput = userInput[:-1]
return userInput
这给我带来了以下错误:
Traceback (most recent call last):
File "flow_class.py", line 1, in <module>
import helper_class
File "helper_class.py", line 1, in <module>
import os, flow_class
File "flow_class.py", line 5, in <module>
debug = getUserInput()
NameError: name getUserInput is not defined
我知道,我显然可以通过总是把“六氯环己烷”作为获取UserInput的一个参数来解决这一问题,但这使这一方法的使用复杂化,使之不那么直观。