Importing Module Via Another Module
In module A, I import module B. Then, in module C, I import module A. In module C, will I be able to use the content of module B implicitly via the import of module A, or will I ha
Solution 1:
That should work just fine. However, it would save you some trouble to explicitly import the module as well if only to keep track in your head when looking back at code
If you have any other questions about importing, try taking a gander to this article here
https://docs.python.org/3/reference/import.html
It should help.
Solution 2:
Yes, it will work.
I think however you'll have to do:
import moduleB
rather than:
from moduleB import methodX
Solution 3:
A simple example down below to give you a start but really you should read the basic tutorial and give it a go first
#A.pyimportBdeffunc_in_a():
B.func_from_b#C.pyimportAA.func_in_a():
Solution 4:
It works fine.
If C imports A (C.py : import A
) and A imports B (A.py : import B
) and in B you have a function
deffuncb():
return`foo`
you can call it from module C :
res = A.B.funcb()
and it will give res = 'foo'
Post a Comment for "Importing Module Via Another Module"