domain2idna
raw JSON → 1.12.4 verified Mon Apr 27 auth: no python
A Python tool to convert domains (or files containing domain lists) to IDNA (Punycode) format. Current version 1.12.4 supports Python >=3.6.2, <4.0. Release cadence is irregular with maintenance updates.
pip install domain2idna Common errors
error AttributeError: module 'domain2idna' has no attribute 'get' ↓
cause The 'get' function was deprecated and removed in newer versions.
fix
Use 'from domain2idna import convert' and call 'convert()' instead.
error TypeError: convert() missing 1 required positional argument: 'to_transform' ↓
cause The 'convert()' function requires a string argument representing the domain.
fix
Pass the domain as a string: convert('example.com')
Warnings
deprecated The 'get' function was deprecated in v1.10.1 and removed in later versions. Use 'convert' instead. ↓
fix Replace 'get()' with 'convert()'.
gotcha The library may return the input unchanged if it is already ASCII or contains common hostnames like 'localhost'. Check the documentation for ignored domains. ↓
fix Be aware that certain strings (e.g., 'localhost', '0.0.0.0') are ignored and returned as-is.
Imports
- convert
from domain2idna import convert - get wrong
from domain2idna import getcorrectfrom domain2idna import convert
Quickstart
from domain2idna import convert
result = convert('münchen.de')
print(result) # Output: xn--mnchen-3ya.de