Skip to main content

BitFlag

PyPi release

A simple bit flag class for Python 🐍.

Installation

$ pip install bitflag

Usage

# 1. import the "BitFlag" class.
from bitflag import BitFlag

# 2. initialize a BitFlag instance with any number of string, flag arguments.
bf = BitFlag("flagA", "flagB", "flagC")

# 3. run operations on those bit flags!

# set – Set one or more bit flags.
bf.set("flagB", "flagC")

# unset – Unset one or more bit flags.
bf.unset("flagB")

# has – Check if one or more bit flags have been set.
bf.has("flagC")

# toggle – Toggle one or more bit flags.
bf.toggle("flagA", "flagB", "flagC")

# reset – Reset (unset) all bit flags.
bf.reset()

# flip – Flip all bit flags.
bf.flip()

# keys - iterate over flag keys.
for k in bf.keys():
    print(k)

# values - iterate over flag values.
for v in bf.values():
    print(v)

# items - iterate over flag keys and values.
for k,v in bf.items():
    print(k, v)

# str - informal string representation.
str(bf)

# repr - formal string representation.
repr(bf)

# int - integer representation.
int(bf)

License

MIT © Travis Clarke

Metadata

Release files for bitflag 2.0.0

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

Source distribution (sdist)

Source distribution for bitflag 2.0.0
File Size Uploaded
bitflag-2.0.0.tar.gz 3.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bitflag 2.0.0
File Interpreter ABI Platform
bitflag-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 6.7 kB

Release files / bitflag-2.0.0.tar.gz

Download URL bitflag-2.0.0.tar.gz
Size 3.0 kB
Tags Source
SHA-256 checksum
How to use checksums
be70a28616b91a35417c52dd1e0d4f248c5c2e26c96473553b3d52671604874e
BLAKE2b-256 checksum
How to use checksums
9006e9655376cf5c3c4a2ab2372f1ae90b504d1fd34987a5c2c687727b3746f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.7.0

Release files / bitflag-2.0.0-py3-none-any.whl

Download URL bitflag-2.0.0-py3-none-any.whl
Size 3.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
023a96bd0879eb93871dcd2442cd9f6451f0e2c48be55d554d5dae9599cd8cb3
BLAKE2b-256 checksum
How to use checksums
68dd3bc190c0f1a51f16d6023f79d61372b08e6a5990c9a88b99a1a50c61ccf5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.7.0

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.0.1

2 release files

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