Skip to content
/ main Public

For those that think `if __name__ = "__main__"` is ugly

Notifications You must be signed in to change notification settings

flipbit03/main

Repository files navigation

@main

PyPI - Python Version PyPI - Version

@main decorator which runs the tagged function if the current module is being executed as a script.

No more if __name__ == "__main__": all over the place.

That's it!

Installation

pip install python-main # or
poetry add python-main # ...

Usage

from python_main import main

A = 10
B = 20


@main
def do_print():
    """This will run if this module is executed."""
    print(A + B)

About

For those that think `if __name__ = "__main__"` is ugly

Resources

Stars

Watchers

Forks

Languages