Hi Javier! On 10 Jan., 15:26, javier <vengor...@gmail.com> wrote: > def _sage_(self): > """ > Override of ExpectElement._sage_ method. Aiming for a better > conversion. Initially just for matrices! > """ > if self.IsMatrix(): > ring = self[1,1].Ring().sage() > return self._matrix_(ring) > else: # If we don't know how to deal with this, return to > the default. > return ExpectElement._sage_(self)
Yep, this is what I meant. Perhaps, for providing an additional layer of safety, one, might put the "if" part in a try-except clause, such as try: if self.IsMatrix(): ring = self[1,1].Ring().sage() return self._matrix_(ring) except ...: # insert the expected kind of error to be catched here pass # If we don't know how to deal with this, return to the default. return ExpectElement._sage_(self) Cheers, Simon
-- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org