Python Glossary Русский

all Python 3until 3.13Removed from the standard libraryterm

sunau

removed modules

Read and write Sun AU (.au) audio. Removed in Python 3.13 — use wave for WAV files; third-party libraries read AU.

Syntax

import sunau  # до 3.13

sunau.open() handled .au files, the format of Sun workstations and the early web: setnchannels/setsampwidth/setframerate and writeframes for writing, getparams() and readframes() for reading. PEP 594 dropped it as a format hardly anyone uses. There is no direct stdlib replacement for AU. If you choose the format, write WAV: the wave module has almost the same interface, and the code is ported by replacing sunau with wave. soundfile can read .au; the standard-sunau package on PyPI restores the old module.

Examples

# Python 3.13+
try:
    import sunau
except ModuleNotFoundError as e:
    print(type(e).__name__)  # → ModuleNotFoundError
# Python 3.13+
import wave
with wave.open('note.wav', 'wb') as w:
    w.setparams((1, 2, 8000, 0, 'NONE', 'not compressed'))
    w.writeframes(bytes(20))
with wave.open('note.wav', 'rb') as r:
    print(r.getnframes(), r.getsampwidth())  # → 10 2
import sunau
with sunau.open('note.au', 'wb') as w:
    w.setnchannels(1)
    w.setsampwidth(2)
    w.setframerate(8000)
    w.writeframes(bytes(20))
with sunau.open('note.au', 'rb') as r:
    print(r.getnframes(), r.getsampwidth())  # → 10 2

See also

Common errors

Open in the full glossarydocs.python.orgReport an inaccuracy