hasattr() or "x in y"?

Mark Lawrence breamoreboy at yahoo.co.uk
Fri Mar 11 17:05:25 EST 2016


On 11/03/2016 21:53, Charles T. Smith wrote:
> On Fri, 11 Mar 2016 21:44:27 +0000, Charles T. Smith wrote:
>
>>  From the performance point of view, which is better: - hasattr()
>> - x in y
>>
>> TIA
>> cts
>
>
> I just realized that "in" won't look back through the class hierarchy...
> that clearly makes them not interchangable, but given we're only
> interested in the current dict...
>

Dict, don't you mean collection?  Or, to put it another way, what 
exactly were you originally asking?

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence




More information about the Python-list mailing list