Skip to content

test if running as "main"

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.txt
Notifications You must be signed in to change notification settings

jamesabel/ismain

Repository files navigation

PyPI version PyPI downloads codecov License Supported Python versions Dependabot status

Installation

pip install ismain

Usage

from ismain import is_main

#
# Same as:
# 
#     if "__name__" == __main__:
# 
# ... but more readable.
#
if is_main():
    print("Hello from main.")

Overhead

The ismain function introduces some overhead compared to the native Python if __name__ == "__main__": construct. However, the absolute overhead is on the order of 10s of milliseconds on modern hardware, so it's generally negligible for many applications.

See the benchmark results for more details.

About

test if running as "main"

Resources

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.txt

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors