From 3daaced0eeb4bdf7fa029506f8b2a011c269ccc5 Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Thu, 18 Mar 2021 23:42:29 -0400 Subject: [PATCH] =?UTF-8?q?Python=20=E7=9A=84=E7=89=B9=E6=AE=8A=E5=8F=98?= =?UTF-8?q?=E9=87=8F=20=5F=5Fname=5F=5F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/VariableName/ImportVarName.py | 13 +++++++++++++ tests/VariableName/VarName.py | 14 ++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 tests/VariableName/ImportVarName.py create mode 100644 tests/VariableName/VarName.py diff --git a/tests/VariableName/ImportVarName.py b/tests/VariableName/ImportVarName.py new file mode 100644 index 0000000..7def4cd --- /dev/null +++ b/tests/VariableName/ImportVarName.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- + +# Python __name__ module ImportVarName +# Author - HoneyMoose(huyuchengus@gmail.com) +# Link Article - https://www.ossez.com/t/python-name/13393 + + +print("ImportVarName __name__ = %s" % __name__) + +if __name__ == "__main__": + print("ImportVarName is being run directly") +else: + print("ImportVarName is being imported") diff --git a/tests/VariableName/VarName.py b/tests/VariableName/VarName.py new file mode 100644 index 0000000..3a26128 --- /dev/null +++ b/tests/VariableName/VarName.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- + +# Python __name__ module Test +# Author - HoneyMoose(huyuchengus@gmail.com) +# Link Article - https://www.ossez.com/t/python-name/13393 + +import ImportVarName + +print("Main VarName __name__ = %s" % __name__) + +if __name__ == "__main__": + print("VarName is being run directly") +else: + print("VarName is being imported")