Skip to main content

has-flag

Check if argv has a specific flag.

This is a port of the Node.js package has-flag to Python.

Install

python3 -m pip install -U has-flag

(That strange-looking setup command is because I've found it to be the most reliable. The pip command often aliases to python 2, and pip3 often installs to the wrong Python package directory.)

Usage

from has_flag import has_flag

has_flag('unicorn');
#>>> True

has_flag('--unicorn');
#>>> True

has_flag('f');
#>>> True

has_flag('-f');
#>>> True

has_flag('foo=bar');
#>>> True

has_flag('foo');
#>>> False

has_flag('rainbow');
#>>> False
$ python3 foo.py -f --unicorn --foo=bar -- --rainbow

License

MIT

Contact

A library by Shawn Presser. If you found it useful, please consider joining my patreon!

My Twitter DMs are always open; you should send me one! It's the best way to reach me, and I'm always happy to hear from you.

Metadata

Release files for has-flag 0.1.1

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

Source distribution (sdist)

Source distribution for has-flag 0.1.1
File Size Uploaded Provenance
has-flag-0.1.1.tar.gz 2.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for has-flag 0.1.1
File Interpreter ABI Platform
has_flag-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 5.9 kB

Release files / has-flag-0.1.1.tar.gz

Download URL has-flag-0.1.1.tar.gz
Size 2.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2ade83150630ce9058d4ab07c57f65c10e6d894e8c90a2275b14a9185a3bc533
BLAKE2b-256 checksum
How to use checksums
29b9782833207ae14b8c7e882d1bcb807b77a64c43de8c29dbd0abb66cade5cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.6 CPython/3.9.2 Darwin/20.3.0

Release files / has_flag-0.1.1-py3-none-any.whl

Download URL has_flag-0.1.1-py3-none-any.whl
Size 3.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7db35c8fff4d58c9e483868dc1271387e1e838d545ab9734eddeeb8b5378f2ac
BLAKE2b-256 checksum
How to use checksums
dfbdd31d0622ee34802ab5b18e631b3d671f096a8649436591447da67a5b0413
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.6 CPython/3.9.2 Darwin/20.3.0

Security for has-flag 0.1.1

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files 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