Maybe add a different function rather add a flag? Something like shutil.remove_dir_files().
Victor Le 25 août 2016 4:32 AM, "Nick Jacobson via Python-ideas" < [email protected]> a écrit : > I've been finding that a common scenario is where I want to remove > everything in a directory, but leave the (empty) root directory behind, not > removing it. > > So for example, if I have a directory C:\foo and it contains subdirectory > C:\foo\bar and file C:\foo\myfile.txt, and I want to remove the > subdirectory (and everything in it) and file, leaving only C:\foo behind. > > (This is useful e.g. when the root directory has special permissions, so > it wouldn't be so simple to remove it and recreate it again.) > > A number of ways to do this have been offered here: > http://stackoverflow.com/questions/185936/delete-folder-contents-in-python > > But it'd be simpler if there were an optional parameter added to > shutil.rmtree, called removeroot. It would default to true so as to not > break any backward compatibility. If it's set to false, then it leaves the > root directory in place. > > Thanks, > > Nick > > > _______________________________________________ > Python-ideas mailing list > [email protected] > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ Python-ideas mailing list [email protected] https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
