Module import question
황병희
soyeomul at doraji.xyz
Sun Aug 9 04:24:18 EDT 2020
Gabor Urban <urbangabo at gmail.com> writes:
> Hi guys,
>
> I have a quite simple question but I could not find the correct answer.
>
> I have twoo modules A and B. A imports B. If I import A in a script, Will
> be B imported automatically? I guess not, but fő not know exactly.
>
> Thanks for your answer ín advance,
#+BEGIN_SRC: sh + python
(bionic)soyeomul at localhost:~/222$ cat b.py
name = "b"
(bionic)soyeomul at localhost:~/222$ cat a.py
import b
name = "a"
(bionic)soyeomul at localhost:~/222$ cat c.py
import a
print(a.name) # a.py's name
print(a.b.name) # b.py's name
(bionic)soyeomul at localhost:~/222$ python3 c.py
a
b
(bionic)soyeomul at localhost:~/222$
#+END_SRC
Sincerely, Byung-Hee
--
^고맙습니다 _白衣從軍_ 감사합니다_^))//
More information about the Python-list
mailing list