This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: xml.etree.ElementTree: add feature in write to create directories also like mkdir -p
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.9
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: i11u, serhiy.storchaka
Priority: normal Keywords:

Created on 2021-10-04 06:07 by i11u, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg403120 - (view) Author: Terunobu Inaba (i11u) Date: 2021-10-04 06:07
In the xml.etree.ElementTree module, the function "write(args)" (https://docs.python.org/ja/3/library/xml.etree.elementtree.html) does not seem to have a function like "-p" in "mkdir -p" in UNIX system, i.e., it will raise an error when some directories in the path argument do not exist in your PC.

I find this a bit uncomfortable. So, I would like to extend this function to be able to create directories only if they does not already exist.
msg403128 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-10-04 10:50
open() does not create parent directories either. And no any function in the stdlib which creates a file does it. It would be rather error-prone if they do, because you can create a file at wrong place.

So just create a directory if you need to, and let the code to raise an exception to report your errors.
History
Date User Action Args
2022-04-11 14:59:50adminsetgithub: 89523
2021-10-04 10:50:17serhiy.storchakasetstatus: open -> closed

nosy: + serhiy.storchaka
messages: + msg403128

resolution: rejected
stage: resolved
2021-10-04 06:07:10i11ucreate