In mailman.122.1253409745.2807.python-l...@python.org MRAB
pyt...@mrabarnett.plus.com writes:
kj wrote:
In mailman.107.1253369463.2807.python-l...@python.org MRAB
pyt...@mrabarnett.plus.com writes:
If, for example, you're
going to copy a file, it's a good idea to check beforehand that
On Sep 19, 9:22 pm, MRAB pyt...@mrabarnett.plus.com wrote:
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.
Strongly agree. Furthermore, with LBYL it's often easier to give a
user clearer error messages
In mailman.107.1253369463.2807.python-l...@python.org MRAB
pyt...@mrabarnett.plus.com 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?
TIA,
kynn
--
kj wrote:
In mailman.107.1253369463.2807.python-l...@python.org MRAB
pyt...@mrabarnett.plus.com 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(...),
On 2009-09-20, MRAB pyt...@mrabarnett.plus.com wrote:
kj wrote:
In mailman.107.1253369463.2807.python-l...@python.org MRAB
pyt...@mrabarnett.plus.com 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
On Sep 18, 11:54 am, kj no.em...@please.post wrote:
I've often come across the idea that good Python style deals with
potential errors using an EAFP (easier to ask forgiveness than
permission) strategy rather than a LBYL (look before you leap)
strategy.
For example, LBYL would look like
On Sep 18, 3:05 pm, Sean DiZazzo half.ital...@gmail.com wrote:
On Sep 18, 11:54 am, kj no.em...@please.post wrote:
I've often come across the idea that good Python style deals with
potential errors using an EAFP (easier to ask forgiveness than
permission) strategy rather than a LBYL
In 254eac4d-ce19-4af9-8c6a-5be8e7b0f...@u16g2000pru.googlegroups.com Sean
DiZazzo half.ital...@gmail.com writes:
On Sep 18, 11:54=A0am, kj no.em...@please.post wrote:
I've often come across the idea that good Python style deals with
potential errors using an EAFP (easier to ask forgiveness
You can access the exception object which gives you greater detail.
try:
os.unlink(some_file)
except OSError, e:
print e.errno
print e.strerror
if e.errno == 2:
pass
else:
raise
I do this myself in a lot of places, almost exactly like
kj wrote:
For example, LBYL would look like this:
if os.path.isfile(some_file):
os.unlink(some_file)
In contrast, EAFP would look like this:
try:
os.unlink(some_file)
except OSError:
pass
The two version aren't equal. The first one suffers from a race
condition which
On Sep 18, 5:23 pm, Christian Heimes li...@cheimes.de wrote:
kj wrote:
For example, LBYL would look like this:
if os.path.isfile(some_file):
os.unlink(some_file)
In contrast, EAFP would look like this:
try:
os.unlink(some_file)
except OSError:
pass
The two version
On 2009-09-19, Christian Heimes li...@cheimes.de wrote:
kj wrote:
For example, LBYL would look like this:
if os.path.isfile(some_file):
os.unlink(some_file)
In contrast, EAFP would look like this:
try:
os.unlink(some_file)
except OSError:
pass
The two version aren't
12 matches
Mail list logo