Re: [sage-devel] Re: UniqueRepresentation: class vs. class_with_category

2015-08-29 Thread Daniel Krenn
On 2015-08-29 16:19, Simon King wrote: Hi Daniel, On 2015-08-29, Daniel Krenn wrote: Ok, thanks. I will use _is_category_initialized() Just to be clear: Whether you should take type(self).__base__ or type(self) *additionally* depends on whether you have an extension type. _is_category_initia

[sage-devel] Re: UniqueRepresentation: class vs. class_with_category

2015-08-29 Thread Simon King
Hi Daniel, On 2015-08-29, Daniel Krenn wrote: > Ok, thanks. I will use _is_category_initialized() Just to be clear: Whether you should take type(self).__base__ or type(self) *additionally* depends on whether you have an extension type. _is_category_initialized() is not enough. Best regards, Sim

Re: [sage-devel] Re: UniqueRepresentation: class vs. class_with_category

2015-08-29 Thread Daniel Krenn
On 2015-08-29 15:15, Simon King wrote: On 2015-08-29, Daniel Krenn wrote: Let self be the parent in question, and assume that the underlying class is a Python class. Then, you can test by self._is_category_initialized() whether or not the category framework is actually used by self. If it is, th

[sage-devel] Re: UniqueRepresentation: class vs. class_with_category

2015-08-29 Thread Simon King
Hi Daniel, On 2015-08-29, Daniel Krenn wrote: > I thought about something similar, but this does not solve my problem, > that I have a couple if classes derived from C, which all should use the > same methodand, ideally, I don't want to override each of these to > take care of the correct

Re: [sage-devel] Re: UniqueRepresentation: class vs. class_with_category

2015-08-29 Thread Daniel Krenn
On 2015-08-29 12:09, Eric Gourgoulhon wrote: I would endow the parent class C with a method new_instance(), as in the following example: Thanks. sage:classC(Parent,UniqueRepresentation): :def__init__(self,data,category=Sets()): :Parent.__init__(self,category=category) :self._data

Re: [sage-devel] Re: UniqueRepresentation: class vs. class_with_category

2015-08-29 Thread Eric Gourgoulhon
Hi, I would endow the parent class C with a method new_instance(), as in the following example: sage: class C(Parent, UniqueRepresentation): : def __init__(self, data, category=Sets()): : Parent.__init__(self, category=category) : self._data = data : def n