Use isinstance instead of type.
authorRadek Brich <radek.brich@devl.cz>
Wed, 17 Aug 2011 21:11:47 +0200
changeset 10 ec1d47e6fe09
parent 9 7175ed629a76
child 11 762513aacc87
Use isinstance instead of type.
tuikit/backend_curses.py
tuikit/editfield.py
tuikit/menu.py
--- a/tuikit/backend_curses.py	Sun Jul 31 13:04:39 2011 +0200
+++ b/tuikit/backend_curses.py	Wed Aug 17 21:11:47 2011 +0200
@@ -252,7 +252,7 @@
         if not self.testclip(x, y):
             return
         try:
-            if type(c) is str and len(c) == 1:
+            if isinstance(c, str) and len(c) == 1:
                 self.screen.addstr(y, x, c)
             else:
                 self.screen.addch(y, x, c)
@@ -267,7 +267,7 @@
 
 
     def hline(self, x, y, w, c=' '):
-        if type(c) is str:
+        if isinstance(c, str):
             s = c*w
         else:
             s = [c]*w
--- a/tuikit/editfield.py	Sun Jul 31 13:04:39 2011 +0200
+++ b/tuikit/editfield.py	Wed Aug 17 21:11:47 2011 +0200
@@ -10,7 +10,7 @@
         Widget.__init__(self, width, 1)
 
         self.code = locale.getpreferredencoding()
-        if not type(value) is str:
+        if not isinstance(value, str):
             value = str(value, self.code)
 
         self.value = value
--- a/tuikit/menu.py	Sun Jul 31 13:04:39 2011 +0200
+++ b/tuikit/menu.py	Wed Aug 17 21:11:47 2011 +0200
@@ -98,7 +98,7 @@
 
     def run_selected(self):
         if self.selected and self.selected[1] is not None:
-            if type(self.selected[1]) is str:
+            if isinstance(self.selected[1], str):
                 self.emit('activate', self.selected[1])
             elif isinstance(self.selected[1], Widget):
                 self.selected[1].show()