Reading Until EOF
Kirk Strauser
kirk at strauser.com
Tue Oct 21 16:10:08 EDT 2003
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
At 2003-10-21T18:27:57Z, "Scott Brady Drummonds" <scott.b.drummonds.nospam at intel.com> writes:
> Per my experience with C++, this does not qualify as "exceptional
> behavior". Frankly, it is accepted. I'd like to save the exceptions for
> true exceptions. My next guess:
But it *is* exceptional behavior for the file read to fail. The normal
behavior is for the call to succeed, right?
Exceptions are handy for all sorts of things. One of my projects uses
something like:
class Success(Exception):
def __init__(self, added = 0, deleted = 0, modified = 0):
self.added = added
self.deleted = deleted
self.modified = modified
to hold return values from various calls. I use it like:
try:
SomeDatabaseQuery()
except Success, result:
print 'Just added %d new entries.' % result.added
except:
print 'The query failed.'
Don't limit yourself to a particular style simply because of the name.
- --
Kirk Strauser
The Strauser Group
Open. Solutions. Simple.
http://www.strausergroup.com/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
iD8DBQE/lYgS5sRg+Y0CpvERAm9uAKCQsxlz2U7OgR/WI3FLSJKmACO0mwCePe9H
d9mWtYpgEYOoDe7XvYjBm4E=
=2ZUb
-----END PGP SIGNATURE-----
More information about the Python-list
mailing list