__pycache__, one more good reason to stck with Python 2?
Peter Otten
__peter__ at web.de
Tue Jan 18 04:04:24 EST 2011
Carl Banks wrote:
> On Jan 17, 6:29 pm, Alice Bevan–McGregor <al... at gothcandy.com> wrote:
>> find . -name \*.pyc -exec rm -f {} \;
>>
>> vs.
>>
>> rm -rf __pycache__
>>
>> I do not see how this is more difficult, but I may be missing something.
>
>
> Well the former deletes all the pyc files in the directory tree
> whereas the latter only deletes the top level __pycache__, not the
> __pycache__ for subpackages. To delete all the __pycache__s you'd
> have to do something like this:
>
> file . -name __pycache__ -prune -exec rm -rf {} \;
>
> or, better,
>
> file . -name __pycache__ -prune | xargs rm -rf
>
> Still not anything really difficult. (I don't think a lot of people
> know about -prune; it tells find don't recursively descend.)
What's the advantage of 'find ... | xargs ...' over 'find ... -exec ...'?
More information about the Python-list
mailing list