retry in try:...except:
Dan Parisien
dan at eevolved.com
Sun Feb 11 16:48:07 EST 2001
Tim Peters wrote:
> [Dan Parisien]
> > Does something like this exist
> >
> > def getval(self, key)
> > try:
> > return self.__keys[key]
> > except KeyError:
> > self.__keys[key] = None
> > retry #!!!!
> return self.__keys.setdefault(key, None)
ick :)
> or (more obscure to my eyes):
> return self.__keys.setdefault(key)
yuck :)
I understand though.
I would be a big fan of things like this
#------
forever:
data = socket.recv(...)
do_something(data)
if condition == 1:
break
#------
do:
something_fancy()
while(condition != false)
#-------
try:
something()
except:
fix_possible_error()
retry
#-------
for i in indexes(list):
do_something( list[i] )
#-------
obj = Widget()
setSize(w, h)
setPos(x, y)
setBGColor(0)
Those things are lacking or are not documented (documented in a foot note
to a sub page of a section of a chapter doesn't count ;) IMHO.
That would increase the ease of coding in python (which is already higher
than any programming language I know).
I know these are things that keep getting brought up... Maybe there's a
reason ;)
peace,
Dan
More information about the Python-list
mailing list