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-1.0.0.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: bitflag-1.0.0.tar.gz
  • Upload date:
  • Size: 3.1 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-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8557144734efd606c86d3b758ff70644bcbb068d8e6a20885036b65f21317ba9
MD5 308bd752e7151e9d1f7ba0388e6b8b64
BLAKE2b-256 20f66bafd864c2e55f25cf3a5c3eead3e4d0b57712a991f8a79cd29822da7749

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bitflag-1.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-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c532befe974898a4d80131b5eafc62deee06d00fb0484c5b4519a8c3304e2737
MD5 0bf6b4ef4c99a2d20a3dc7b3896ecb33
BLAKE2b-256 81837531e66d8dc7451b33a199e4f091f1c9676a5d162c20f6145d6a96c2a953

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