将ruby脚本转换为python
我的问题如下 我有一个像这样的ruby脚本将ruby脚本转换为python,python,Python,我的问题如下 我有一个像这样的ruby脚本 module parent module son_1 ... some code here end module son_2 ... some code here end class one ... some code here end class two ... some code here end end 我需
module parent
module son_1
... some code here
end
module son_2
... some code here
end
class one
... some code here
end
class two
... some code here
end
end
我需要把这个脚本翻译成python,但是
我有点困惑
首先我做了这个:
- 我将“模块父级”转换为python包
- 我在包中制作了“module son_1”和“module son_2”两个文件
- 最后,我在这个包的
文件(“模块父级”)中定义了最后两个类\uuuuu init\uuuu
- 这个解决方案正确吗
- 如果是,还有更好的吗
- parent/
------- __init__.py << empty file or can have classes if you need, that way python will treat parent as a package
------- son_1.py
------- son_2.py
- test.py
在文件系统上应该是这样的:
- parent/
------- __init__.py << empty file or can have classes if you need, that way python will treat parent as a package
------- son_1.py
------- son_2.py
- test.py
啊!!是的,谢谢你的快速回答啊!!是的,谢谢你的快速回答