wasm-demo/demo/ermis-f/python_m/cur/1387

35 lines
1.3 KiB
Plaintext

From: mstenber at cc.Helsinki.FI (Markus Stenberg)
Date: 28 Apr 1999 14:16:24 +0300
Subject: try vs. has_key()
References: <aahzFAM4oJ.M7M@netcom.com> <yWOT2.6007$8m5.9320@newsr1.twcny.rr.com> <Pine.SUN.3.95-heb-2.07.990423140345.21577A-100000@sunset.ma.huji.ac.il> <7g51q6$1pt$1@vvs.superst.iae.nl> <aahzFAvFCz.3Lr@netcom.com>
Message-ID: <al8eml50zcn.fsf@myntti.helsinki.fi>
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)