Skip to content

Commit

Permalink
vm.print
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowone committed Aug 6, 2024
1 parent 08e7ec9 commit 0bd1a3e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions vm/src/vm/vm_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,15 @@ impl VirtualMachine {
.invoke(args, self)
}

/// Same as __builtins__.print in Python.
/// A convenience function to provide a simple way to print objects for debug purpose.
// NOTE: Keep the interface simple.
pub fn print(&self, args: impl IntoFuncArgs) -> PyResult<()> {
let ret = self.builtins.get_attr("print", self)?.call(args, self)?;
debug_assert!(self.is_none(&ret));
Ok(())
}

#[deprecated(note = "in favor of `obj.call(args, vm)`")]
pub fn invoke(&self, obj: &impl AsObject, args: impl IntoFuncArgs) -> PyResult {
obj.as_object().call(args, self)
Expand Down

0 comments on commit 0bd1a3e

Please sign in to comment.