Skip to content

Instantly share code, notes, and snippets.

@arsho
Created December 12, 2016 06:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arsho/e1ca2d757844c192ef5c4b112bc99095 to your computer and use it in GitHub Desktop.
Save arsho/e1ca2d757844c192ef5c4b112bc99095 to your computer and use it in GitHub Desktop.
Python __name__ functionality. First run a.py file. Then run b.py file to see the difference
if __name__ == '__main__':
print("Running directly from a.py")
else:
print("a.py is imported")
# run python a.py
import a
# run python b.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment