Skip to main content

A tool for converting numbers from one base to another, TheTechRobo edition

Project description

python-radix library

The library contains tools for representing natural numbers in a given base, or to current any numeral representing a natural number between two bases. Currently any base between 2 and 36 is supported.

Python-radix usage examples

Python-radix has both procedural and object-oriented solutions.

Procedural way example

# to convert numeral 4 from base 10 to base 2
>>> cast('4', 10, 2)
'100'

# to convert the integer 4 to base 2
>>> cast(4, None, 2)

Note that since the first argument is a number, rather than a numeral, the second parameter is irrelevant, so None is used.

Object oriented way example

>>> # create an object to find the base 2 representation of any natural number
>>> new = Converter(None, 2)
>>> new.convert(4)
'100'
>>> # create an object to find the base 2 representation of any base 10 numeral
>>> new = Converter(10, 2)

>>> new.convert('4')
'100'

Using characters as digits

# the digits 0 through 9 are succeeded by the lower case ASCII alphabet
>>> cast('a', 16, 10)
'10'

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

python-radix-ng-0.3.linux-x86_64.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

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

python_radix_ng-0.3-py2.py3-none-any.whl (3.6 kB view details)

Uploaded Python 2Python 3

File details

Details for the file python-radix-ng-0.3.linux-x86_64.tar.gz.

File metadata

  • Download URL: python-radix-ng-0.3.linux-x86_64.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.3

File hashes

Hashes for python-radix-ng-0.3.linux-x86_64.tar.gz
Algorithm Hash digest
SHA256 24fbac3bebcc2fef04d592d6465778a32075b9d3637cbe48b55a3467aa75dc31
MD5 89d1a59e13ea61a5f2a0c9448c6b7e07
BLAKE2b-256 16d9938fdcc549c9616a196329b4f85634e3f4fd5f910f3bcd31b8d5e2a60ad0

See more details on using hashes here.

File details

Details for the file python_radix_ng-0.3-py2.py3-none-any.whl.

File metadata

  • Download URL: python_radix_ng-0.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.3

File hashes

Hashes for python_radix_ng-0.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 87fbc1b00d96d9156f310389590a690bf8516ccc1d3cadc6cd68b329d75e14c7
MD5 67254be7afd9486a9e6a3c006d70847b
BLAKE2b-256 50fd3b24bce03760edc91f008b63deb4dd888bfeb6927ca8f6105b10b208a008

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