"Emilio Casbas" <[email protected]> wrote
If I enter a not existent key, an exception is raised. How can I control the not existent key and assign him a default value?
One way is to use the get() method of a dictionary:
d = {'Exists': True}
d['Exists']
True
d['Error']
Traceback!!!....
d.get('Error',False)
False HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ _______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
