我需要更有经验的开发人员为我的数据结构提供一些输入。
我想做什么?
我正在为映射表编写转换器。它有效,但我认为有一种更好的方法来设置结构。
当然,业务逻辑应该易于设置,但同时,结构仍应可读。有人有建议吗?
映射表:
System A | 4 | 5 |5* |6x | 6x* | 6y | 6y* | 6c | 6c* | 7x | 7x* |
System B | | 4 |5 |6x | 6x* | 6y | 6y* | 6c | 6c* | 7x | 7x* |
System C | X0 |X1 |X2 | X3 | X4 | X5 | X6 | X7 |
有三种不同的分级系统(A,B,C)。每个等级都由彼此大致相当的等级组成。
例如。“X4”(系统 C)可以转换为“6y”或“6y”*(系统 A)
例如。“6c”(系统B)可以转换为“X5”(系统C)
当前结构
mapping = {
"name": ["System A", "System B", "System C"],
"grade": {
0: ["4", "", "X0"],
1: ["5", "4", "X0"],
2: ["5*", "5", "X1"],
# ... and so on.
}
}
# the current standard is "System A"
input_system = 0
# the input is the index number for the grade
input_grade = 4
# expected output: "In system A it is 6x*."
print(f"In {mapping.name[input_system]} it is {mapping.grade[input_grade][input_system]}.")
翻过高山走不出你
相关分类