Re: [sage-devel] Re: Question about coercion model

2024-02-13 Thread Gareth Ma
I see, thanks for the clear explanation, indeed "100" * a is absurd. Still, should there at least be some mechanism to handle `int` in this code path? Since the path for `_mul_` works: ``` sage: class Number(Parent): : def __init__(self, x): self.x = x : def __repr__(self): ret

[sage-devel] Re: Question about coercion model

2024-02-12 Thread Nils Bruin
On Monday 12 February 2024 at 03:21:36 UTC-8 Gareth Ma wrote: sage: class Number: : def __init__(self, x): self.x = x : def __repr__(self): return f"Number({self.x})" : def _acted_upon_(self, other, _): return Number(self.x * ZZ(other)) I think that would have horrible