Python 3.3+Linuxosfunction
os.removexattr
os — extended attributes (xattr)
Remove an extended attribute from a file.
Syntax
os.removexattr(...)
For a missing attribute it raises OSError rather than staying silent. System attributes in the security and trusted namespaces cannot be removed by ordinary users. The name is given in full, with its prefix.
Examples
import os
open('xattr_demo.txt', 'w').close()
os.setxattr('xattr_demo.txt', 'user.author', b'anna') # → ? только Linux: подготовили атрибут, чтобы было что удалять
os.removexattr('xattr_demo.txt', 'user.author') # → ? только Linux: атрибут удалён, функция возвращает None
print(os.listxattr('xattr_demo.txt')) # → [] — атрибутов не осталось
print(os.removexattr('xattr_demo.txt', 'user.author')) # → OSError (ENODATA) — повторное удаление, атрибута уже нет
See also
Common errors
Open in the full glossarydocs.python.orgReport an inaccuracy