How to create abstract properties in python abstract classes

In the following code, I create a base abstract class Base. I want all the classes that inherit from Base to provide the name property, so I made this property an @abstractmethod. Then I created a subclass of Base, called Base_1, which is meant to supply some functionality, but still remain abstract. There is no … Read more

Is it possible to make abstract classes in Python?

How can I make a class or method abstract in Python? I tried redefining __new__() like so: class F: def __new__(cls): raise Exception(“Unable to create an instance of abstract class %s” %cls) but now if I create a class G that inherits from F like so: class G(F): pass then I can’t instantiate G either, … Read more

How to unit test abstract classes: extend with stubs?

I was wondering how to unit test abstract classes, and classes that extend abstract classes. Should I test the abstract class by extending it, stubbing out the abstract methods, and then test all the concrete methods? Then only test the methods I override, and test the abstract methods in the unit tests for objects that … Read more

Creating an abstract class in Objective-C

I’m originally a Java programmer who now works with Objective-C. I’d like to create an abstract class, but that doesn’t appear to be possible in Objective-C. Is this possible? If not, how close to an abstract class can I get in Objective-C? 2Best Answer 21 Typically, Objective-C class are abstract by convention only—if the author … Read more