all Python 3Files & I/Ofunction
csv.unregister_dialect()
csv — dialects
Removes a dialect from the registry by name. After that the name can no longer be passed to reader and writer.
Syntax
csv.unregister_dialect(name)
Removing a name that is not registered is not silent: it raises csv.Error 'unknown dialect', not KeyError, so that is what you must catch. Even the built-in 'excel' can be removed: a reader call without dialect keeps working, but dialect='excel' then fails. The function is mostly used in tests to clean up a temporary dialect.
Examples
import csv
csv.register_dialect('tmp', delimiter='|')
csv.unregister_dialect('tmp')
try:
csv.unregister_dialect('tmp')
except csv.Error as e:
print(e) # → unknown dialect
See also
Open in the full glossarydocs.python.orgReport an inaccuracy