summaryrefslogtreecommitdiffstats
path: root/Lib/curses
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>2003-09-02 11:52:06 (GMT)
committerAndrew M. Kuchling <amk@amk.ca>2003-09-02 11:52:06 (GMT)
commitf19f8610faa2119b14b9af72415f450e3ab7a1d3 (patch)
treec3c8dd09e936e53e91aecec5897464552a174eba /Lib/curses
parent0ec5288d09e2ac3652c8a88f644417629ed1e759 (diff)
downloadcpython-f19f8610faa2119b14b9af72415f450e3ab7a1d3.zip
cpython-f19f8610faa2119b14b9af72415f450e3ab7a1d3.tar.gz
cpython-f19f8610faa2119b14b9af72415f450e3ab7a1d3.tar.bz2
Modernize code a bit: use isinstance instead of type(); return True/False
Diffstat (limited to 'Lib/curses')
-rw-r--r--Lib/curses/has_key.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/Lib/curses/has_key.py b/Lib/curses/has_key.py
index cac0cd1..0987952 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,