On 18Jan2021 16:49, Random832 <random...@fastmail.com> wrote: >On Wed, Jan 13, 2021, at 08:31, Antonio Cavallo wrote: >> I've found myself typing too many time this: >> pathlib.Path("some-dir-name").mkdir(parent=True, exist_ok=True) >> >> Wouldn't be better to have a pathlib.Path.makedirs with parent/exist_ok >> set to True by default? > >Worth mentioning, that os.makedirs does not set exist_ok to True by >default. I have been baffled by this decision, but not following it in >pathlib would arguably be an inconsistency.
I fall into the other camp. I like exists_ok=False because it is safer behaviour. If I'm writing code which expects to make a directory, I _almost always_ want that directory to be _new_ and empty, unused by some other purpose. If exists_ok were True by default it would be very easy to write code which accidentally used a directory belonging to something else. I would far rather such reuse required a little thought on my part, by requiring specific calling out that exists_ok=True. Cheers, Cameron Simpson <c...@cskk.id.au> _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/7XC5KMZYUM57ZYMZAHLV356KED55UXPP/ Code of Conduct: http://python.org/psf/codeofconduct/