Skip to main content

A bit flag class for python

Project description


PyPi release

A simple bit flag class for Python 🐍.


$ pip install bitflag


# 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.

# has – Check if one or more bit flags have been set.

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

# reset – Reset (unset) all bit flags.

# flip – Flip all bit flags.

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

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

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

# str - informal string representation.

# repr - formal string representation.

# int - integer representation.


MIT © Travis Clarke

Project details

Download files

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

Files for bitflag, version 2.0.0
Filename, size File type Python version Upload date Hashes
Filename, size bitflag-2.0.0.tar.gz (3.0 kB) File type Source Python version None Upload date Hashes View
Filename, size bitflag-2.0.0-py3-none-any.whl (3.6 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page