Skip to main content

A python module where a number can be converted to its binary string and binary string to number. Note: binary string which will be recieved and provided will be in string format for early releases.

binary_parser is a simple python library where users can convert an integer to its binary string and vice versa.

Installation

pip install binary-parser

number-parser requires Python 3.6+.

Usage

The library provides the following common use cases.

Converting a binary string to an integer

>>> import binary_parser
>>> binary_parser.parse_to_num('1011')
'11'
>>> binary_parser.parse_to_num('000')
'0'
>>> binary_parser.parse_to_num('01')
'1'

Converting an integer to its binary format

Arguments passed can be a string or an integer type.

>>> import binary_parser
>>> binary_parser.parse_to_binary('7')
'111'
>>> binary_parser.parse_to_binary(1)
'1'
>>> binary_parser.parse_to_binary('0')
'0'

Checking if given string is binary or integer

>>> import binary_parser
>>> binary_parser.which_parser('1010')
'Input 1010 could be either binary or a number'
"binary string: 1010 number: 10"
>>> binary_parser.which_parser(12)
'Input 12 is a number'
"number: 12"
>>> binary_parser.which_parser('00101')
'Input 00101 could be either binary or a number'
"binary string: 00101 number: 101"
>>> binary_parser.which_parser(b'10011')
'Input b'10011' is a binary string'
"binary string: b'10011'"

Change Log

0.0.1 (07/02/2022)

  • First Release

0.0.2 (08/02/2022)

0.0.3 (08/02/2022)

0.0.4 (26/02/2022)

  • bytes usage and readme changes

Release files for binary-parser 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for binary-parser 0.0.4
File Size Uploaded
binary_parser-0.0.4.tar.gz 3.6 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for binary-parser 0.0.4
File Interpreter ABI Platform
binary_parser-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 3.7 MB

Release files / binary_parser-0.0.4.tar.gz

Download URL binary_parser-0.0.4.tar.gz
Size 3.6 MB
Tags Source
SHA-256 checksum
How to use checksums
5d9c964df29fff93913c7f5586dd117740bb31e2003f3dabcef2c93bd1c8dd39
BLAKE2b-256 checksum
How to use checksums
8cce56bd4d5fba2eab522dfd779fc349bdfb3fe85cf4114332dfec874db61a1c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

Release files / binary_parser-0.0.4-py3-none-any.whl

Download URL binary_parser-0.0.4-py3-none-any.whl
Size 3.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
12f58e10d24fd06017a5d7142e4d1c9e8fb48440ec1e5eec6743e24a798e39c6
BLAKE2b-256 checksum
How to use checksums
3dfa8dafb3eb210df6672a0229e736bb07d15a3c420e4cb8b253e79606459581
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

3 release files

0.0.2

1 release file

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page