I want to separate code in different class and I want to put them in different files. However, these classes depend on each other.
main.py: lib / _ init _. Py : lib / b .py: Is it possible in Python? Instead of importing modules on module names, Other modules can be imported inside the function.
from Lib Import A, BDF main (): a = a () b = b () a .hello () B.Hello () if __name__ == '__main__': main ()
import lib. B "A" def: __init __ (self): print "A" def hello (self): print "hello a" b = b ()
import lib.A class B (): def __init __ (self): print "B" def Hello (self): Print "Hello B" A = A ()
pydev debugger: start traceback (most recent call final): file "eclipse - dragon / plugins / org .pythth_thumb_dev_2.7.1.2012100913 / pysrc / pydevd.py ", line 1397, & lt; Module & gt; Debugger.run (Setup ['File'], None, None) File "Eclipse-Python / Plugins / or org.pythth Configuration .7.1.2012100913 / pysrc / pydevd.py", line 1090, pydev_imports .execfile, globals, local people) # script file "main.py", line 2, in the & lt; Module & gt; Lib Import A, B file from "lib / __ init__.py", line 1, & lt; Module & gt; Import file "lib / a.py", line 1, & lt; Module & gt; Import Lib B import error: B
square b (): def __init __ (self): print "b" def hello (self): import lib.A print "hello b" a = a ()
No comments:
Post a Comment