Skip to content

EDM115/booleanfix

Repository files navigation

booleanfix

The most useless pip package so far
PyPI - Version PyPI - Downloads Pepy Total Downlods

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 and undefined as None. v1.2.0 added the ability to use none as None.

Behind the scenes

true = True
false = False
none = None
null = None
undefined = None

Usage

  1. Install the package in your repo
pip install booleanfix

If you use a requirements file, add this line to it :

booleanfix==1.2.0
  1. The classic way
import booleanfix as bf

print(isinstance(bf.true, bool))
print(bf.false == False)
  1. The easy way
from booleanfix import true, false

print(isinstance(true, bool))
print(false == False)
  1. 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