From: mstenber at cc.Helsinki.FI (Markus Stenberg) Date: 28 Apr 1999 14:16:24 +0300 Subject: try vs. has_key() References: <7g51q6$1pt$1@vvs.superst.iae.nl> Message-ID: X-UID: 1387 aahz at netcom.com (Aahz Maruch) writes: > It appears that the second parameter for get() (to specify a value > different from None when the key is not found) is new to 1.5.2. In > 1.5.1 you still have to do the following: Not quite. mstenber at melkki ~>python Python 1.5.1 (#1, Nov 10 1998, 13:21:44) [GCC 2.7.2.3] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> {}.get("foo","bar") 'bar' >>> -Python 1.5-ly yours, Markus -- "Schizophrenia, like the Unicorn, is described in various ways by various people. And its elimination, like the capture of the Unicorn, appears to require some special conditions, not all of which have yet been specified. Finally, whether or not those conditions exist, belief in their existence has had significant consequences." - Schizophrenia, Behavioural Aspects (Salzinger, 1972)