[Python-Dev] Extending os.chown() to accept user/group names

Charles-François Natali neologix at free.fr
Wed May 25 20:45:24 CEST 2011

>> While we're at it, adding a "recursive" argument to this shutil.chown
>> could also be useful.
> I don't like the idea of a recursive flag. I would prefer a "map-like"
> function to "apply" a function on all files of a directory. Something
> like shutil.apply_recursive(shutil.chown)...

I was also thinking about this possibility.
The advantage is that we could factor-out the recursive walk logic to
make it available for other functions (chown, chmod...).
It doesn't map well to the Unix command, though.

> You can do all of this with an appropriate application of os.walk().

Then, I wonder why shutil.copytree and shutil.rmtree are provided.
Recursive rm/copy/chown/chmod are extremely useful in system
administration scripts. Furthermore, it's not as simple as it seems
because of symlinks, see for example http://bugs.python.org/issue4489

More information about the Python-Dev mailing list