[Python-checkins] python/dist/src/Lib/curses has_key.py,1.3,1.4
akuchling at users.sourceforge.net
akuchling at users.sourceforge.net
Tue Sep 2 05:52:08 EDT 2003
Update of /cvsroot/python/python/dist/src/Lib/curses
In directory sc8-pr-cvs1:/tmp/cvs-serv5574
Modified Files:
has_key.py
Log Message:
Modernize code a bit: use isinstance instead of type(); return True/False
Index: has_key.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/curses/has_key.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** has_key.py 2 Sep 2003 11:44:44 -0000 1.3
--- has_key.py 2 Sep 2003 11:52:06 -0000 1.4
***************
*** 161,175 ****
def has_key(ch):
! if type(ch) == type( '' ): 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
#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 __name__ == '__main__':
--- 161,178 ----
def has_key(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 False
#Check the current terminal description for that capability;
#if present, return true, else return false.
! if _curses.tigetstr( capability_name ):
! return True
! else:
! return False
if __name__ == '__main__':
More information about the Python-checkins
mailing list