Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/TurtleArt/tautils.py
diff options
context:
space:
mode:
authorWalter Bender <walter.bender@gmail.com>2013-05-05 12:22:37 (GMT)
committer Walter Bender <walter.bender@gmail.com>2013-05-05 12:22:37 (GMT)
commit530ac9230d7774ed2409d1e45420e1922e05bf53 (patch)
treeba1bd85107d15b72a7dd2b006833d09fb86868f3 /TurtleArt/tautils.py
parentfba8e527fd22b61f0e94b0f87073ead603db61e3 (diff)
change type()== to isisintance
Diffstat (limited to 'TurtleArt/tautils.py')
-rw-r--r--TurtleArt/tautils.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/TurtleArt/tautils.py b/TurtleArt/tautils.py
index 69814c0..caeb047 100644
--- a/TurtleArt/tautils.py
+++ b/TurtleArt/tautils.py
@@ -110,9 +110,7 @@ def chr_to_ord(x):
def strtype(x):
''' Is x a string type? '''
- if type(x) == str:
- return True
- if type(x) == unicode:
+ if isinstance(x, (str, unicode)):
return True
return False
@@ -174,7 +172,7 @@ def json_load(text):
def _tuplify(tup):
''' Convert to tuples '''
- if type(tup) is not list:
+ if not isinstance(tup, list):
return tup
return tuple(map(_tuplify, tup))
@@ -268,9 +266,9 @@ def data_from_file(ta_file):
def data_from_string(text):
''' JSON load data from a string. '''
- if type(text) == str:
+ if isinstance(text, str):
return json_load(text.replace(']],\n', ']], '))
- elif type(text) == unicode:
+ elif isinstance(text, unicode):
text = text.encode('ascii', 'replace')
return json_load(text.replace(']],\n', ']], '))
else:
@@ -314,7 +312,7 @@ def save_picture(canvas, file_name):
cr = cairo.Context(img_surface)
cr.set_source_surface(x_surface)
cr.paint()
- if type(file_name) == unicode:
+ if isinstance(file_name, unicode):
img_surface.write_to_png(str(file_name.encode('ascii', 'replace')))
else:
img_surface.write_to_png(str(file_name))
@@ -523,7 +521,7 @@ def show_button_hit(spr, x, y):
def numeric_arg(value):
''' Dock test: looking for a numeric value '''
- if type(convert(value, float)) is float:
+ if isinstance(convert(value, float), float):
return True
return False
@@ -699,7 +697,7 @@ def find_blk_below(blk, namelist):
''' Find a specific block below this block. '''
if blk == None or len(blk.connections) == 0:
return
- if type(namelist) != list:
+ if not isinstance(namelist, list):
namelist = [namelist]
group = find_group(blk)
for gblk in group: