Skip to content

Commit ef1fef2

Browse files
authored
added idea behind __name__ == __main__
1 parent 442a568 commit ef1fef2

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
# see result by right click and run on both mymath.py and test.py and see difference
3+
4+
def add(a, b):
5+
return a+b
6+
7+
print(__name__)
8+
if __name__ == "__main__": # this is same as main method in c++ or other pro. lang.
9+
print(add(10,16))
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
3+
import mymath
4+
5+
print(mymath.add(7,6))

0 commit comments

Comments
 (0)