exceptions
Aleksei Guzev
aleksei.guzev at bigfoot.com
Fri Oct 6 00:19:41 EDT 2000
what one should d when he wants smth like this:
def f(d,s,e):
for i in range(s,e):
print d[i]
D={1:'blah1', 2:'blah2', 3:'blah3', 7:'blah7', 10:'blah10'}
try: f(D, 1, 30)
except KeyError(key):
D[key]='blah%d'%key
RESUME
It's a simple example. Assume f(d,s,e) is defined by another programmer deep
in a module.
It seems to be not a good idea to provide f with a procedural object as an
argument for every exception... Because those programmer SHOULD NOT know
anything of the dictionary I provide. If one defines an object then he
should handle everything concerned with it. This shortens the code and
increases speed.
Aleksei Guzev
More information about the Python-list
mailing list