Skip to content
Snippets Groups Projects
Commit eb2784e8 authored by Damien George's avatar Damien George
Browse files

py/objtuple: Allow to use inplace-multiplication operator on tuples.

parent cb7ecda9
No related branches found
No related tags found
No related merge requests found
......@@ -148,7 +148,8 @@ mp_obj_t mp_obj_tuple_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs) {
mp_seq_cat(s->items, o->items, o->len, p->items, p->len, mp_obj_t);
return MP_OBJ_FROM_PTR(s);
}
case MP_BINARY_OP_MULTIPLY: {
case MP_BINARY_OP_MULTIPLY:
case MP_BINARY_OP_INPLACE_MULTIPLY: {
mp_int_t n;
if (!mp_obj_get_int_maybe(rhs, &n)) {
return MP_OBJ_NULL; // op not supported
......
......@@ -11,6 +11,11 @@ a = (1, 2, 3)
c = a * 3
print(a, c)
# inplace multiplication
a = (1, 2)
a *= 2
print(a)
# unsupported type on RHS
try:
() * None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment