diff options
Diffstat (limited to 'TurtleArt/taconstants.py')
-rw-r--r-- | TurtleArt/taconstants.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/TurtleArt/taconstants.py b/TurtleArt/taconstants.py index 0a3cc23..469f5d3 100644 --- a/TurtleArt/taconstants.py +++ b/TurtleArt/taconstants.py @@ -156,18 +156,28 @@ class ColorObj(object): self.color = color def __int__(self): - if self.color.color is None: - return int(self.color.shade) + if hasattr(self.color, 'color'): + if self.color.color is None: + return int(self.color.shade) + else: + return int(self.color.color) else: - return int(self.color.color) + return int(self.color) def __float__(self): - return float(int(self)) + if hasattr(self.color, 'color'): + return float(int(self)) + else: + return float(self.color) def __str__(self): + if isinstance(self.color, (float, int, bool)): + return str(self.color) return str(self.color.name) def __repr__(self): + if isinstance(self.color, (float, int, bool)): + return str(self.color) return str(self.color.name) |