From: Michael Orlitzky Date: Fri, 12 Mar 2021 13:11:47 +0000 (-0500) Subject: eja: use hasattr() to avoid a try/except. X-Git-Url: http://gitweb.michael.orlitzky.com/?p=sage.d.git;a=commitdiff_plain;h=82d3e5bb067d73eb0aa557d234da0f9723b456e8 eja: use hasattr() to avoid a try/except. --- diff --git a/mjo/eja/eja_algebra.py b/mjo/eja/eja_algebra.py index 8e52252..4a1c6f9 100644 --- a/mjo/eja/eja_algebra.py +++ b/mjo/eja/eja_algebra.py @@ -779,13 +779,9 @@ class FiniteDimensionalEJA(CombinatorialFreeModule): if elt.parent().superalgebra() == self: return elt.superalgebra_element() - try: - # Try to convert a vector into a column-matrix... + if hasattr(elt, 'column'): + # Convert a vector into a column-matrix... elt = elt.column() - except (AttributeError, TypeError): - # and ignore failure, because we weren't really expecting - # a vector as an argument anyway. - pass if elt not in self.matrix_space(): raise ValueError(msg)