Coding technique: distinguish using type or abc?

Marko Rauhamaa marko at pacujo.net
Thu Jan 9 10:04:56 EST 2020


ram at zedat.fu-berlin.de (Stefan Ram):
>     if type( object ) is list:

I would recommend isinstance() because:

   >>> isinstance(True, int)
   True
   >>> type(True) is int
   False


Marko


More information about the Python-list mailing list