Skip to main content

bda.basen

Project description

Module to represent integers as any other based representation string.

There exist direct converter functions.

>>> from bda.basen import str2int
>>> from bda.basen import int2str

>>> ref = 'abcde'

>>> int2str(12345, ref)
'deddea'

>>> str2int('abcde', ref)
194

Or a direct representation call for a 62 ascii based base.

>>> from bda.basen import base62
>>> term = base62(100)
>>> str(term)
'1C'

>>> term = base62('1D')
>>> int(term)
101

This works also with uuids, which is with ~22 chars less than the default hex with 32 chars:

>>> term = base62(uuid.uuid4())

basej uses 91 chars ascii as base (no backslash, no single/double quotes, no control chars). With this a chance to get 20 chars for a uuid is high:

>>> term = basej(uuid.uuid4())

Source Code and Contributions

If you want to help with the development (improvement, update, bug-fixing, …) of bda.basen this is a great idea! Submit issues or pull requests!

The code is located at github.

Maintainer is Jens Klein, Robert Niederreiter and the BlueDynamics Alliance developer team. We appreciate any contribution and if a release is needed to be done on pypi, please just contact one of us dev@bluedynamics dot com

Code is licensed under GPL v2. History =======

1.1 (2016-05-25)

  • Support for python uuid module [jensens]

  • more generic basex base class and special basej class. [jensens]

1.0

  • initial implementation [rnixx, jensens]

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

bda.basen-1.1.tar.gz (3.4 kB view details)

Uploaded Source

File details

Details for the file bda.basen-1.1.tar.gz.

File metadata

  • Download URL: bda.basen-1.1.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for bda.basen-1.1.tar.gz
Algorithm Hash digest
SHA256 a716102ebb2d7d6067df88ba4dab373dd254ece5693345718e5cdb8fbfbdeab0
MD5 6828fc33a42416f662b97f692ee27900
BLAKE2b-256 5f1b4c03c420caa9d75f93925d62c5756351f8204bd3bc6470fd39f6375407bb

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