From 568035cdd65fbe07e998bcf8a5824570cdb2a883 Mon Sep 17 00:00:00 2001 From: Thomas Ferreira de Lima Date: Wed, 1 Aug 2018 11:56:50 -0400 Subject: [PATCH] adding __rmul__ in all objects with __mul__ --- src/pya/pya/pyaModule.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pya/pya/pyaModule.cc b/src/pya/pya/pyaModule.cc index 793f4f2ad..90b03a704 100644 --- a/src/pya/pya/pyaModule.cc +++ b/src/pya/pya/pyaModule.cc @@ -2698,6 +2698,11 @@ PythonModule::make_classes (const char *mod_name) add_python_doc (*c, mt, mid, tl::to_string (tr ("This method enables iteration of the object"))); alt_names.push_back ("__iter__"); + } else if (name == "__mul__") { + // Adding right multiplication + // Rationale: if pyaObj * x works, so should x * pyaObj + add_python_doc (*c, mt, mid, tl::to_string (tr ("This method is also available as '__mul__'"))); + alt_names.push_back ("__rmul__"); } for (std::vector ::const_iterator an = alt_names.begin (); an != alt_names.end (); ++an) {