From: Andrew M. Kuchling Date: Tue, 2 Sep 2003 11:52:06 +0000 (+0000) Subject: Modernize code a bit: use isinstance instead of type(); return True/False X-Git-Tag: v2.4a1~1662 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f19f8610faa2119b14b9af72415f450e3ab7a1d3;p=python Modernize code a bit: use isinstance instead of type(); return True/False --- diff --git a/Lib/curses/has_key.py b/Lib/curses/has_key.py index cac0cd11c1..0987952588 100644 --- a/Lib/curses/has_key.py +++ b/Lib/curses/has_key.py @@ -160,17 +160,20 @@ _capability_names = { } def has_key(ch): - if type(ch) == type( '' ): ch = ord(ch) + if isinstance(ch, str): + ch = ord(ch) # Figure out the correct capability name for the keycode. capability_name = _capability_names.get(ch) if capability_name is None: - return 0 + return False #Check the current terminal description for that capability; #if present, return true, else return false. - if _curses.tigetstr( capability_name ): return 1 - else: return 0 + if _curses.tigetstr( capability_name ): + return True + else: + return False if __name__ == '__main__': # Compare the output of this implementation and the ncurses has_key,