translating a ruby script to python -


my problem following

i have ruby script looking this

module parent      module son_1         ... code here     end      module son_2         ... code here     end      class 1         ... code here     end      class 2         ... code here     end  end 

and need script translated python little confused ?

first made :

  • i turned "module parent" python package

  • i made "module son_1" , "module son_2" 2 files inside package

  • and defined last 2 classed in __init__ file of package ( "module parent" )

my questions :

  • is solution correct ?

  • and if , there better 1 ?

it should on file system :

- parent/   ------- __init__.py << empty file or can have classes if need, way python treat parent package   ------- son_1.py   ------- son_2.py - test.py 

then in actual code in test.py :

from parent import son_1, son_2, one, 2 c = one('something') b = son_1.something() #or import parent import parent.son_1 import parent.son_2 c = parent.one('something') b = parent.son_1.something() 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -