Granularity of OSError

Grant Edwards invalid at invalid.invalid
Sun Sep 20 03:35:21 CEST 2009

On 2009-09-20, MRAB <python at> wrote:
> kj wrote:
>> In <mailman.107.1253369463.2807.python-list at> MRAB <python at> writes:
>>> If, for example, you're going to copy a file, it's a good idea
>>> to check beforehand that there's enough space available for
>>> the copy.
>> How do you do that?
> There's os.statvfs(...), although that's Unix only.
> The point is that it's sometimes a good idea to do a cheap
> check first before attempting an operation that's 'expensive'
> even when it fails.

It's also important to note than under some circumstances, the
side-effects of that particular failure (filling up a disk
partition) can be unpleasant -- particularly if you do it as
root. Incoming Mail gets bounced/dropped, cron jobs fail, etc.


More information about the Python-list mailing list