Opened 15 years ago

Closed 15 years ago

#401 closed defect (worksforme)

list * integer works but integer * list doesn't work

Reported by: dmharvey Owned by: somebody
Priority: minor Milestone: sage-2.8.3
Component: basic arithmetic Keywords:
Cc: Merged in:
Authors: Reviewers:
Report Upstream: Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

In SAGE 2.6, you can do list * integer but not integer * list. Either they should both work (more like python) or neither of them should work (for internal consistency).

sage: [3, 4, 5] * 2
 [3, 4, 5, 3, 4, 5]

sage: 2 * [3, 4, 5]
---------------------------------------------------------------------------
<type 'exceptions.TypeError'>             Traceback (most recent call last)

/home/dmharvey/sage-2.6/<ipython console> in <module>()

/home/dmharvey/sage-2.6/element.pyx in element.RingElement.__mul__()

/home/dmharvey/sage-2.6/element.pyx in element.bin_op_c()

<type 'exceptions.TypeError'>: unsupported operand parent(s) for '*': 'Integer Ring' and '<type 'list'>'

Change History (1)

comment:1 Changed 15 years ago by mabshoff

  • Milestone set to sage-2.8.3
  • Resolution set to worksforme
  • Status changed from new to closed

Work's for me with Sage 2.8.2:

sage: [3,4,5]*3
[3, 4, 5, 3, 4, 5, 3, 4, 5]
sage: 3*[4,5,6]
[4, 5, 6, 4, 5, 6, 4, 5, 6]

Cheers,

Michael

Note: See TracTickets for help on using tickets.