Skip to main content

A library designed to streamline simple operations, loops and contexts.

Project description

Image
Version

Version

pages-build-deployment

Installation

This package can be installed & upgraded using pip:

pip install -U plaintools

Introduction

PlainTools is a Python 3 library designed to introduce new features and fix awkward common interactions present in the Python 3 native ecosystem.

Most functions are prefixed with p (as in pt.plist or pt.pround) to avoid homonyms. The p stands for Plain and are the namesake of this package.

Examples

Some simple, yet relevant examples using the Plain Number(pt.pnumber) function are:

>>> import PlainTools as pt

>>> 0.1 * 3
0.30000000000000004

>>> pt.pnumber(0.1 * 3)
0.3 # Deals with float imprecision errors.
؜

>>> 5 / 3
1.6666666666666667

>>> pt.pnumber("5 / 3")
1.666... # '...' present only in string format; The true value is still float(5/3).
؜

>>> 1 / 73
0.0136986301369863

>>> pt.pnumber(1 / 73)
0.013698630136986301369863... # Can detect long chains of repeating decimals!
؜

>>> 0.9999999999999988
0.9999999999999988

>>> pt.pnumber(0.9999999999991234)
0.99999999999912 # No loss of precision up to 14 literal digits.
؜

>>> 0.00000000001 ** 3
9.999999999999999e-34

>>> pt.pnumber(0.00000000001 ** 3)
1e-33 # Corrects scientific-notated float imprecisions as well.
؜

>>> pt.pnumber("math.pi") # A safe variation of 'eval()' is used, as shown below!
3.141592653589793

# https://stackoverflow.com/a/1933463/26469850
>>> pt.pnumber("import shutil; shutil.rmtree('/.')") # Example of malicious use.
PlainTools.SEVAL.UnsafeError: Invalid syntax in expression
؜

Simple, right?

Countless more examples can be found in the Library's Documentation Page, so please check it out!

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

plaintools-1.2.241009.2.tar.gz (864.7 kB view details)

Uploaded Source

Built Distribution

plaintools-1.2.241009.2-py3-none-any.whl (865.4 kB view details)

Uploaded Python 3

File details

Details for the file plaintools-1.2.241009.2.tar.gz.

File metadata

  • Download URL: plaintools-1.2.241009.2.tar.gz
  • Upload date:
  • Size: 864.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for plaintools-1.2.241009.2.tar.gz
Algorithm Hash digest
SHA256 f6c92d73cf50a85366e23c736bd0bfc1861238f93981361f10a6d08cf3e1cddd
MD5 1742dea56f83d92d45823e6bf369c719
BLAKE2b-256 78b18b96887d8b1c474a27ed69957625b721e7db599ac5faf396c0f0ba582e7c

See more details on using hashes here.

File details

Details for the file plaintools-1.2.241009.2-py3-none-any.whl.

File metadata

File hashes

Hashes for plaintools-1.2.241009.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bc10a9fca0eb1fd0879b76c113c0ee9a55c7e587833a6f6cd704fe2b5f5e8642
MD5 ccffb4388cd18654bcd6abe696db24ab
BLAKE2b-256 be0dc2488645040c5fa74adee33446803ad3be516a84f77fac1fb077d608aea2

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