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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: bitflag-1.0.1.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-1.0.1.tar.gz
Algorithm Hash digest
SHA256 62a287965a3cb2fa04e441a9134c558417c59f23486cb55ff10ad9ef434a208e
MD5 d7fb5293ec301e88070e00951dc56d8a
BLAKE2b-256 e6fa4a9d724a76dc4fd735e64cf907227b8fed12cea8949a824aafbd04655d00

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bitflag-1.0.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e5c02c517f55d7211efd3d178725bdef38c29b10dbee51778ea6a0d527fcdba3
MD5 64d964e2f3b06857160023002a3c8b1a
BLAKE2b-256 553f0546ed504ac0424bf34de3d9f69ca223fc5089aa4017dd5f87a911658cc6

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