Skip to content Skip to sidebar Skip to footer

Why Python Print My Output Two Times When I Import The Same File In Which I Am Printing?

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 import inheritan

Solution 1:

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.

Post a Comment for "Why Python Print My Output Two Times When I Import The Same File In Which I Am Printing?"