Permalink
Browse files

Added __str__ to tuple object to fix remaining specs.

  • Loading branch information...
1 parent 306c990 commit 8ee1e88971cf9b9b4b2bf6df8fb5f60c3fde6c4f @vic committed Mar 15, 2012
View
@@ -3,5 +3,4 @@
import imported
import foo.bar
-
print(imported.__doc__)
View
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+"IMPORTED"
def foo():
"""imported module"""
@@ -41,7 +41,7 @@ def inspect
end
python_method(:__repr__) do |s|
- "\"#{s.gsub('"', '\"')}\""
+ "\'#{s.gsub('"', '\"')}\'"
end
end
@@ -3,6 +3,8 @@ module Environment
class Tuple
include PythonObjectMixin
+ attr_reader :tuple
+
def initialize(rbx_tuple)
@tuple = rbx_tuple
py_init(TupleType)
@@ -11,6 +13,12 @@ def initialize(rbx_tuple)
python_class_c :TupleType, [ObjectBase], 'tuple', 'tuple' do
+ extend FunctionTools
+
+ python_method(:__str__) do |t|
+ '(' + t.tuple.map { |i| i.to_py.py_send(:__repr__) }.join(', ') + ')'
+ end
+
end
end
end
View
@@ -1,5 +1,5 @@
#! typhon examples/import.py
#! python examples/import.py
imported
-imported module
BAR
+IMPORTED
@@ -1,7 +1,7 @@
#! typhon examples/numbers.py
#! python examples/numbers.py
boom
-<type 'int'> <type 'long'> <type 'int'>
+<type 'int'> <type 'int'> <type 'int'>
11
9995
10000000000

0 comments on commit 8ee1e88

Please sign in to comment.