Comment #13 on issue 2125 by nicolas.pourcelot: Using Integers as python
slices.
http://code.google.com/p/sympy/issues/detail?id=2125
Note that you can implement __index__ method, and still keep a special case
concerning lists:
class Two(object):
def __int__(self):
return 2
def __index__(self):
return 2
def __mul__(self, y):
if isinstance(y, list):
return [2*x for x in y]
def __rmul__(self, y):
if isinstance(y, list):
return [2*x for x in y]
t=Two()
[1,1]*t
[2, 2]
t*[1,1]
[2, 2]
(However, I'd still prefer S(2)*[1, 1] to return [1, 1, 1, 1] instead of
[2, 2]. I find this a bit more "pythonic".)
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.