try vs. has_key()

Markus Stenberg mstenber at cc.Helsinki.FI
Wed Apr 28 07:16:24 EDT 1999


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)




More information about the Python-list mailing list