>Date: Sat, 4 Jul 2009 19:52:56 +0100
>From: "Alan Gauld" <[email protected]>
>Message-ID: <[email protected]>
>
>You can miss out a few else clauses, especially after 
>the try/excepts:
>
>-----------
>while get_bool("Continue?"): 
>    try: key = eval(raw_input("Key value of type " + key_typ.__name__ + ": ")) 
>    except StandardError: print "That's not a Python expression!" 
>
>    if not isinstance(key, key_typ): 
>       print "That's not a value of type", key_typ.__name__ else: # User has 
> provided
>    try: val = eval(raw_input("Object of type " + val_typ.__name__ + ": ")) 
>    except StandardError: print "That's not a Python expression!" 
>
>    if not isinstance(val, val_typ): 
>       print "That's not an object of type", val_typ.__name__ 
>    else: # User has provided an object of the correct type 
>       ans[key] = val 
>return ans
>------------

I don't see this, because, if an exception does occur, won't
there be an attempt to access one of the objects 'key', 'val'
before it has been assigned?

Not that this matters in the largely rewritten "Version 0.1":
<http://python.pastebin.com/d7020f124>   (retention: 1 day)

(Is it time for me to get into the comfy chair yet?)  8-P
-- 
Angus Rodgers
_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to