Checking whether type is None
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Sat Jul 28 06:07:27 EDT 2018
On Sat, 28 Jul 2018 09:47:07 +0000, Gilmeh Serda wrote:
> On Tue, 24 Jul 2018 12:33:27 -0700, Tobiah wrote:
>
>> I'm trying to get away from things like:
>>
>> >>> type(thing) is type(None)
>
> How about:
>
> >>> some_thing = None
> >>> type(some_thing).__str__(some_thing)
> 'None'
>
> Equally weird, I'd say, but what the heck...
class Foo:
def __str__(self):
return 'None'
--
Steven D'Aprano
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson
More information about the Python-list
mailing list