Skip to main content

A bit flag class for python

Project description

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

Project details


Download files

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

Source Distribution

bitflag-2.0.0.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

bitflag-2.0.0-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file bitflag-2.0.0.tar.gz.

File metadata

  • Download URL: bitflag-2.0.0.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for bitflag-2.0.0.tar.gz
Algorithm Hash digest
SHA256 be70a28616b91a35417c52dd1e0d4f248c5c2e26c96473553b3d52671604874e
MD5 a48ab3d16c3a43150110103292393ab9
BLAKE2b-256 9006e9655376cf5c3c4a2ab2372f1ae90b504d1fd34987a5c2c687727b3746f4

See more details on using hashes here.

File details

Details for the file bitflag-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: bitflag-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for bitflag-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 023a96bd0879eb93871dcd2442cd9f6451f0e2c48be55d554d5dae9599cd8cb3
MD5 916e6a8839f63f72ccb0531ed39b9fc0
BLAKE2b-256 68dd3bc190c0f1a51f16d6023f79d61372b08e6a5990c9a88b99a1a50c61ccf5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page