Why Python print my output two times when I import the same file in which I am printing?

前端 未结 1 1213
轻奢々
轻奢々 2021-01-26 13:21

I have been playing around with python as I am a beginner in it. I wrote following class Parent which I was reading from Udacity online course.

inheritance.py file

相关标签:
1条回答
  • 2021-01-26 14:10

    Because you program load itself!

    When you run inheritance.py:

    • import inheritance: load inheritance.py once like a module and execute it.
    • execute next.

    So yours prints statement are executed twice.

    You do not have import.

    0 讨论(0)
提交回复
热议问题