Fix for boolean variables in Python
Project description
booleanfix
The most useless pip package so far
The problem
If you come from another programming language, you may have noticed that Python's boolean variables are a bit different. This module aims to fix that, by giving you boolean variables like you're used to.
The solution
This very simple project gives you boolean variables like you're used to. It's as simple as that.
[!NOTE] v1.1.0 added the ability to use
null
andundefined
asNone
. v1.2.0 added the ability to usenone
asNone
.
Behind the scenes
true = True
false = False
none = None
null = None
undefined = None
Usage
- Install the package in your repo
pip install booleanfix
If you use a requirements file, add this line to it :
booleanfix==1.2.0
- The classic way
import booleanfix as bf
print(isinstance(bf.true, bool))
print(bf.false == False)
- The easy way
from booleanfix import true, false
print(isinstance(true, bool))
print(false == False)
- The all-in-one way
from booleanfix import *
print(isinstance(true, bool))
print(false == False)
Example
from booleanfix import *
array = [1, 2, 3, 4, 5]
for i in range(len((array))):
if array[i] % 2 == 0:
array[i] = true
else:
array[i] = false
print(array)
for i in array:
print(type(i), isinstance(i, bool), i)
if null == undefined:
print("null == undefined")
if array[5] == null:
print("array[5] == null")
Contributing
Feel free to open an issue or a pull request if you want to contribute to this project
How to build ?
py -m pip install --upgrade pip build twine setuptools wheel
py -m build
py -m twine check dist/*
# Optional : publish to test.pypi.org
py -m twine upload --repository testpypi dist/*
# Or to pypi.org
py -m twine upload dist/*
How to test ?
py -m pip install --upgrade pytest
py -m pytest
License
This project is licensed under the MIT License - see the LICENSE file for details
Authors
- EDM115 - Initial work - EDM115
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
Built Distribution
File details
Details for the file booleanfix-1.2.0.tar.gz
.
File metadata
- Download URL: booleanfix-1.2.0.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a41e2bed11d2e299bc97152ff921d2ef670ea3788b6dd95fb1d5105974b28007 |
|
MD5 | 58a288550f272f359562e13d76e6e87d |
|
BLAKE2b-256 | 0988a422ccfde954d03ea51768f2d3a96c2b2ed9d442d34869474c5cc6e9dc74 |
File details
Details for the file booleanfix-1.2.0-py3-none-any.whl
.
File metadata
- Download URL: booleanfix-1.2.0-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2a4511a4055acab80f9d110b4b143e23b281d85ae4d654171e3326d08b9c87b |
|
MD5 | 870b53b9a4db48a902f9359f08e0cb37 |
|
BLAKE2b-256 | cb34d91ca4638966c3d4948ec35b384bbc1e2b7b034c231befa6e0d7f334374b |