Skip to main content

Decorated functions as entry points.

Project description


License Version Downloads Discord

Documentation Check Test Coverage

Decorated functions as entry points.

In python, an entry point can be thought of as an explicit function that gets called when the script is run directly from the console.

Defining an entry point requires some boilerplate code, which is abstracted away by this library.


Python 3.7 or above is required.


Installing the library with pip is quite simple:

$ pip install entrypoint

Alternatively, the library can be installed from source:

$ git clone
$ cd entrypoint
$ python -m pip install .


You can add entrypoint as a dependency with the following command:

$ poetry add entrypoint

Or by directly specifying it in the configuration like so:

entrypoint = "^1.3.0"

Alternatively, you can add it directly from the source:

git = ""



Declare the main function as an entry point:

from entrypoint import entrypoint

def main() -> None:
    print("Hello, world!")

Run the script directly from the console:

$ python
Hello, world!

When importing the module, main does not get called:

>>> import file
>>> # no output


Note that main gets called immediately, before any code below can be executed.

def main() -> None:
    print("-> in main")

print("<- outside")
$ python
-> in main
<- outside


It is possible to run main directly:


This method allows to take control over where and when the function gets called.


entrypoint also provides is_main function that resembles the common (and de-facto standard) way of implementing entry points:

from entrypoint import is_main

if is_main(__name__):
    print("Hello, world!")


entrypoint does not provide any specific functionality to run async functions.

Instead, you can specify, for example, a main function that runs its async_main counterpart:

import asyncio

async def async_main() -> None:
    print("Hello, world!")

def main() -> None:


You can find the documentation here.


If you need support with the library, you can send an email or refer to the official Discord server.


You can find the changelog here.

Security Policy

You can find the Security Policy of entrypoint here.


If you are interested in contributing to entrypoint, make sure to take a look at the Contributing Guide, as well as the Code of Conduct.


entrypoint is licensed under the MIT License terms. See License for details.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

entrypoint-1.3.0.tar.gz (5.7 kB view hashes)

Uploaded source

Built Distribution

entrypoint-1.3.0-py3-none-any.whl (5.0 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page