If Dict Contains a particular key
Robert Rawlins - Think Blue
robert.rawlins at thinkbluemedia.co.uk
Wed Apr 25 09:04:36 CEST 2007
Thanks guys for this, glad it was so simple.
I used mikes solution in the end, and it worked a charm.
From: python-list-bounces+robert.rawlins=thinkbluemedia.co.uk at python.org
[mailto:python-list-bounces+robert.rawlins=thinkbluemedia.co.uk at python.org]
On Behalf Of Michael Bentley
Sent: 24 April 2007 18:37
To: python-list at python.org
Subject: Re: If Dict Contains a particular key
On Apr 24, 2007, at 12:28 PM, Robert Rawlins - Think Blue wrote:
I'm Looking to build a quick if/else statement that checks a dictionary for
a key like follows.
If myDict contains ThisKey:
Thats the best way of doing this?
if ThisKey in myDict:
pass # do this
pass # do that
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list