Python alternative (binary) flags
Project description
Python alternative flags
How to install
pip install altflags
How to use
from altflags import Flags, flag
class Permissions(Flags)
view_page = flag(0)
add_message = flag(1)
user = Permission()
user.view_page = True
print(user.view_page)
#
print(user.flags)
# >>> 1
user.add_message = True
print(user.add_message)
# >>> True
print(user.flags)
# >>> 3
user.view_page = False
print(user.view_page)
# >>> False
print(user.flags)
# >>> 2
print("{:0b}".format(user.flags))
# >>> 10
Flag method arguments
The n
argument in altflags.flag(n)
is the bit position of the flag
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
altflags-0.0.1b0.tar.gz
(2.6 kB
view hashes)
Built Distribution
Close
Hashes for altflags-0.0.1b0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98991887e944ad49d7ae358638d7991ca3e0d0af82cd136b5c5027cfa8221598 |
|
MD5 | 205acc73e7d5cc5ed01f6000db2a3de7 |
|
BLAKE2b-256 | f8214093968892c5921d54e2342b4a2e9d4ddc9d45f7c5b0bc18db89c4f2ccfa |