Skip to main content

A custom standard library module for Python

Project description

## pystdlib 🐍

This project is a set of pre-built modules, functions and classes that were made to make your life easier when programming in Python, it works like a Swiss army knife.

## Version

This library is still only in beta version, it is worth mentioning that this means that it is in constant development.

## Instalation

To install it is very simple, just install it via pip `pip install pystdlib` and then you can use it without any problems.

## Contributing

That said, there’s a bunch of ways you can contribute to this project, like by:

  • Giving a star on this repository (this is very important and costs nothing)

  • Reporting a bug

  • Improving this documentation

  • Sharing this project and recommending it to your friends

  • Or you can contribute code by following this guide:

## guide

Hello dev, thank you for thinking about contributing to our project, your help is very important to us.

To facilitate your contribution, I am writing this guide. Because I keep in mind that help from the community is essential for the growth of a project, and contributing here is very simple, just follow this guide and send the pull request.

To contribute, start by forking the repository, then you can start working on the code, here in this repository we use a commit convention, if you don’t know what this is, read this guide: <a href=”https://www. conventionalcommits.org/pt-br/v1.0.0-beta.4/”> conventional commits</a>, We use this convention to facilitate code maintenance, as we can make mistakes in our codes, it’s okay, we are human and can make mistakes, and commits are a history of our changes or contributions. Using this convention we can navigate between the commits and we will be able to find where we added the code that possibly caused an error in the application, so that we can edit the code and fix it or even recover the state before the commit. Right after you finish doing everything, it is very important that you make sure you have finished everything before making the pull request. If you have, make the pull request and briefly explain your changes. What did you do, why did you do it, how did you do it, to facilitate code review.

## Double

Class Overview

The Double class represents double-precision floating-point numbers with customizable precision. It offers arithmetic operations, formatting, and utility methods.

Attributes

precision (int): The number of decimal places to maintain. value (str): The value of the number as a string. Methods

  • __init__(value, precision=None):

Initializes a new Double object with the given value and precision. If precision is not provided, the default precision is used. The value can be an integer, float, or string. _parse(value):

Parses the given value into a string representation, ensuring it has a decimal point and appropriate formatting.

  • __repr__():

Returns a string representation of the Double object, suitable for debugging or evaluation.

  • __str__():

Returns a formatted string representation of the Double object, suitable for display.

  • _format(value):

Formats the given value to the specified precision, ensuring leading zeros and trailing zeros are handled correctly.

  • __add__(other):

Adds the given other value to this Double object. Handles Double, int, and float operands. Returns a new Double object with the result.

  • __sub__(other):

Subtracts the given other value from this Double object. Handles Double, int, and float operands. Returns a new Double object with the result.

  • __mul__(other):

Multiplies this Double object by the given other value. Handles Double, int, and float operands. Returns a new Double object with the result.

  • __truediv__(other):

Divides this Double object by the given other value. Handles Double, int, and float operands. Raises ZeroDivisionError if the divisor is zero. Returns a new Double object with the result.

  • _add(a, b):

Adds two string representations of numbers. Handles different decimal lengths and carries over. Returns the sum as a string.

  • _subtract(a, b):

Subtracts two string representations of numbers. Handles different decimal lengths and borrowing. Returns the difference as a string.

  • _multiply(a, b):

Multiplies two string representations of numbers. Handles different decimal lengths and carries over. Returns the product as a string.

  • _divide(a, b):

Divides two string representations of numbers. Handles different decimal lengths and carries over. Returns the quotient as a string.

  • set_default_precision(precision):

Sets the default precision for all Double objects.

  • get_default_precision():

Gets the default precision for all Double objects.

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

standlib-0.0.3.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

standlib-0.0.3-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file standlib-0.0.3.tar.gz.

File metadata

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

File hashes

Hashes for standlib-0.0.3.tar.gz
Algorithm Hash digest
SHA256 e41a08ff47f760144660af99395a0d173942e90f4b5e0930667483e2c6b3e8cb
MD5 9bb0daa327f46035c7e8d5420967694c
BLAKE2b-256 3621b4f1b8af290f2695c8a090f580ed2aafb6d764c5d07f35c2127782b51124

See more details on using hashes here.

File details

Details for the file standlib-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: standlib-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for standlib-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d8e86cc328e91198eb72173f06d364be8f69f2217907cca0151f2c3de2475632
MD5 0a767a3b8baa92110b86867cfe98a441
BLAKE2b-256 ec22065855e9c3a3f2e341fdc6509b3269f36a3bb959617e0b5973728c35f8fa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page