Poset is a function, which constructs a finite poset, not the poset class, as you can check: sage: type(Poset) <class 'function'> You can also check it by having a look at the source code: sage: Poset??
So when you write Poset.upper_bounds = upper_bounds you are attaching upper_bounds to the function, not to the class of posets. The latter is FinitePoset (actually a subclass of it, name FinitePoset_with_category, which is constructed dynamically via Sage category mechanism). So you should do sage: from sage.combinat.posets.posets import FinitePoset sage: FinitePoset.upper_bounds = upper_bounds Then sage: X = Poset(...) sage: X.upper_bounds(...) shoud work. Le lundi 28 septembre 2020 à 18:29:43 UTC+2, pong a écrit : > For convenient, I would like to add an attribute, upper_bounds, to Poset > objects > > However, after writing the method and issue > Poset.upper_bounds = upper_bounds > > X.upper_bounds(S) complains > > 'FinitePoset_with_category' object has no attribute 'upper_bounds' > > When I try > FinitePoset_with_category.upper_bounds = upper_bounds > > I got > name 'FinitePoset_with_category' is not defined > > So how can one add an attribute to FinitePoset_with_category? > -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/7b4691ad-9bab-4f71-818d-371b8011a42dn%40googlegroups.com.