lib/pycall/utils.rb in pycall-0.1.0.alpha.20170403 vs lib/pycall/utils.rb in pycall-0.1.0.alpha.20170419a

- old
+ new

@@ -77,9 +77,16 @@ def type(pyobj) @type ||= PyCall.eval('type') @type.(pyobj) end + def with(ctx) + __exit__ = PyCall.getattr(ctx, :__exit__) + yield PyCall.getattr(ctx,:__enter__).() + ensure + __exit__.() + end + def format_traceback(pyobj) @format_tb ||= import_module('traceback').format_tb @format_tb.(pyobj) end end