{"id":4218,"library":"python-baseconv","title":"Python Base Converter","description":"Python-baseconv is a lightweight Python module designed to convert numbers from base 10 integers to base X strings and vice versa. It provides predefined converters for common bases like binary, hexadecimal, and Base64, as well as the ability to define custom alphabets. The current version is 1.2.2, with its last release in April 2019, suggesting a maintenance-focused release cadence.","status":"maintenance","version":"1.2.2","language":"python","source_language":"en","source_url":"https://github.com/semente/python-baseconv","tags":["base-conversion","numbers","math","utility","encoding","decoding"],"install":[{"cmd":"pip install python-baseconv","lang":"bash","label":"Install with pip"}],"dependencies":[],"imports":[{"note":"Predefined converters are directly imported from the `baseconv` package, not as submodules of `baseconv` itself.","wrong":"import baseconv.base64","symbol":"base2, base16, base36, base56, base58, base62, base64","correct":"from baseconv import base2, base16, base36, base56, base58, base62, base64"},{"symbol":"BaseConverter","correct":"from baseconv import BaseConverter"}],"quickstart":{"code":"from baseconv import base62, BaseConverter\n\n# Using a predefined converter (e.g., Base62)\nencoded_value = base62.encode(1234567890)\nprint(f\"Encoded to Base62: {encoded_value}\")\ndecoded_value = base62.decode(encoded_value)\nprint(f\"Decoded from Base62: {decoded_value}\")\n\n# Creating a custom converter\nmy_alphabet = '0123456789ABCDEF'\nmy_hex_converter = BaseConverter(my_alphabet)\n\ncustom_encoded = my_hex_converter.encode(255)\nprint(f\"Custom Hex Encoded: {custom_encoded}\")\ncustom_decoded = my_hex_converter.decode(custom_encoded)\nprint(f\"Custom Hex Decoded: {custom_decoded}\")\n","lang":"python","description":"This quickstart demonstrates how to use the predefined base converters and how to create a custom BaseConverter with your own alphabet for encoding and decoding integers."},"warnings":[{"fix":"Ensure your code handles large integers without the 'L' suffix. Test thoroughly in your target Python 3 environment. For new projects, consider alternatives if Python 2 compatibility is a concern or if you need newer Python features/idioms.","message":"The library was originally developed with Python 2.7 in mind, as evidenced by Python 2.7 classifiers on PyPI and use of 'L' suffix for long integers in older examples. While the core functionality generally works in Python 3, active Python 3-specific maintenance might be limited.","severity":"gotcha","affected_versions":"<=1.2.2"},{"fix":"If you need base conversion outside of specific Django signing utilities, use the standalone `python-baseconv` library. For Django-specific signing, refer to `django.core.signing`.","message":"Do not confuse `python-baseconv` with `django.utils.baseconv`. The latter was a private, undocumented module within Django that borrowed code from `python-baseconv` but has been deprecated in Django 4.0 and completely removed in Django 5.0. Directly importing `django.utils.baseconv` will fail in modern Django versions.","severity":"deprecated","affected_versions":"Django >= 4.0 (deprecated), Django >= 5.0 (removed)"},{"fix":"Always provide a valid, non-empty alphabet to `BaseConverter` and ensure the sign character is not part of the alphabet. Implement error handling (e.g., `try-except ValueError`) when decoding user-provided or external base-encoded strings.","message":"The `BaseConverter` class and its methods (`encode`, `decode`) will raise `ValueError` for invalid inputs, such as an empty digit alphabet during instantiation, using a sign character within the digit alphabet, or encountering digits during decoding that are not present in the converter's alphabet.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"search_vec":"'1.2.2':52 '10':18 '2019':59 'abil':43 'alphabet':47 'april':58 'base':2,17,21,33,68 'base-convers':67 'base64':38 'baseconv':6 'binari':35 'cadenc':66 'common':32 'convers':69 'convert':3,14,30 'current':49 'custom':46 'decod':74 'defin':45 'design':12 'encod':73 'focus':64 'hexadecim':36 'integ':19 'last':55 'lightweight':9 'like':34 'mainten':63 'maintenance-focus':62 'math':71 'modul':11 'number':15,70 'predefin':29 'provid':28 'python':1,5,10 'python-baseconv':4 'releas':56,65 'string':23 'suggest':60 'util':72 'versa':26 'version':50 'vice':25 'well':40 'x':22","created_at":"2026-04-12T03:45:59.983808+00:00","updated_at":"2026-04-16T20:16:00.115264+00:00","problems":[{"fix":"Install the package using pip: `pip install python-baseconv`","cause":"The 'baseconv' package is not installed in the current Python environment.","error":"ModuleNotFoundError: No module named 'baseconv'"},{"fix":"Ensure the input string exclusively uses characters defined in the alphabet of the chosen base converter, or use a converter that supports the required characters (e.g., `baseconv.base62` for typical alphanumeric strings).","cause":"The input string provided to a `base_decode` function contains characters that are not part of the specified alphabet for that base converter.","error":"ValueError: Found non-alphabet character in input string"},{"fix":"Provide an integer as the first argument to `base_encode`, for example: `baseconv.base10.encode(123)`","cause":"The `base_encode` function was called with a string as its first argument (the number to encode), but it expects an integer.","error":"TypeError: 'str' object cannot be interpreted as an integer"},{"fix":"Ensure the input to `base_decode` is a string, for example: `baseconv.base10.decode('123')`","cause":"The `base_decode` function was called with a non-string type (such as an integer) as its first argument, but it expects a string to decode.","error":"TypeError: expected string or bytes-like object"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.2.2","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/semente/python-baseconv","docs":null,"changelog":null,"pypi":"https://pypi.org/project/python-baseconv/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-29","next_check":"2026-07-28","install_tag":null}}