intflags
Simplest way to create bit-flags.
$ pip install intflags
Usage
Create any number of intflags by using intflags.get(). You can create a union of any amount using the pipe (|) operator.
>>> import intflags
>>> a, b, c = intflags.get(3)
>>> bin(a | b | c)
'0b111'
>>> flags = a | b
>>> a in flags
True
>>> c in flags
False
Flags can be subtracted.
# ...
>>> new_flags = flags - b
>>> b in new_flags
False
>>> new_flags == a
True
You could use classes as a pseudo-namespace.
>>> class RegexFlags:
... I, L, M, S, U, X = intflags.get(6)
Flags share an internal "namespace" ID to prevent accidental conflicts between sets. This allows multiple sets of flags to exist within the same class or module, without risk of accidentally creating a union between them.
>>> x = intflags.get(1)
>>> y = intflags.get(1)
>>> x | y
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
...
ValueError: Flags must share a namespace to create a union.
License
IntFlags is licensed under the ISC license. A copy of the license is included in the root of this repository and in the source of the module.
Metadata
Release files for intflags 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| intflags-2.0.0.tar.gz | 3.5 kB | Without provenance | Details for intflags-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| intflags-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for intflags-2.0.0-py3-none-any.whl |
Total release size: 7.9 kB
Release files / intflags-2.0.0.tar.gz
| Download URL | intflags-2.0.0.tar.gz |
|---|---|
| Size | 3.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5d2a8881402c3e626eea489d260ea9adde75a5c34d6694d151bd18a753aab9e7
|
|
BLAKE2b-256 checksum How to use checksums |
b8fedc95c7bae794a74b7bee1516930bde4a76957f0a34d951a5581e6a12c11f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.3 CPython/3.8.1 Windows/10
|
Release files / intflags-2.0.0-py3-none-any.whl
| Download URL | intflags-2.0.0-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bfcce38fe07af394eb159149d05cf8818cfcb316bfac75ce6d7abc07434041b9
|
|
BLAKE2b-256 checksum How to use checksums |
5deb36374eba3d37bfbaf1cb0c54d2188c6f7b385dbf4de72358eaac2b215597
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.3 CPython/3.8.1 Windows/10
|
Security for intflags 2.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.