learning python. learning defining functions . need help

MRAB python at mrabarnett.plus.com
Fri Jul 22 14:36:56 EDT 2016


On 2016-07-22 16:41, D'Arcy J.M. Cain wrote:
> On Fri, 22 Jul 2016 08:21:17 -0700
> justin walters <walters.justin01 at gmail.com> wrote:
>> You could also replace that line with:
>>
>>     if stock is None or type(stock) != dict:
>
> Use isinstance().  That handles classes that subclass dict as well.
>
If you're checking that it's a dict, there's no need to check whether 
it's None, because None isn't a dict either!



More information about the Python-list mailing list