Skip to main content

unmain

The end to if __name__ == "__main__":!

Are you tired of writing if __name__ == "__main__": main() at the end of every script?

Ever wished for a cleaner, better, simpler wait to call main()?

Do you enjoy abusing the import system?

Well, today’s your lucky day!

Just import unmain and we’ll do the dirty work for you!

import unmain

def main():
    print("Hello, unmain!")

Wow!

Installation & Usage

Installing and using unmain is easy!

  1. Install
    pip install unmain
  2. Import
    import unmain

That’s it! Unmain will find your main() function and call it for you.

Practical Considerations

Unmain abuses the import system to re-import your main module, then running main() from it. To avoid running global code twice - pleace import unmain at the top of your script file. Any code above the import location will be executed twice.

Additionally, the entire module will execute before main() is run. You can place your main() function anywhere in your script file.

Metadata

Release files for unmain 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for unmain 1.0.0
File Interpreter ABI Platform Actions
unmain-1.0.0-py2.py3-none-any.whl Python 2, Python 3 none any Details for unmain-1.0.0-py2.py3-none-any.whl

Release files / unmain-1.0.0-py2.py3-none-any.whl

Download URL unmain-1.0.0-py2.py3-none-any.whl
Size 2.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
fab2efcba0a5522491f0ce7bdc89bab26af83795b39611b84c7b432f197b00c0
BLAKE2b-256 checksum
How to use checksums
4f34976629ba60631bd6445c203dd20af64199844576d380959731581e3f7be7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.4

Security for unmain 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page