lib/pycall/utils.rb in pycall-0.1.0.alpha.20170224 vs lib/pycall/utils.rb in pycall-0.1.0.alpha.20170226
- old
+ new
@@ -1,7 +1,13 @@
module PyCall
module Utils
+ def dir(pyobj)
+ value = LibPython.PyObject_Dir(pyobj)
+ return value.to_ruby unless value.null?
+ raise PyError.fetch
+ end
+
def int(pyobj)
@int ||= PyCall.eval('int')
@int.(pyobj)
end
@@ -24,9 +30,14 @@
end
def type(pyobj)
@type ||= PyCall.eval('type')
@type.(pyobj)
+ end
+
+ def format_traceback(pyobj)
+ @format_tb ||= import_module('traceback').format_tb
+ @format_tb.(pyobj)
end
end
extend Utils
end