I am complete new to Python , and i want to convert a Java project to Python, this is a a basic sample of my code in Java: (i truly want to know how to work with abstract classes and polymorphism in Python)
public abstract class AbstractGrandFather {
protected ArrayList list = new ArrayList();
protected AbstractGrandFather(){
list.add(getGrandFatherName());
}
protected abstract String getGrandFatherName();
}
public abstract class AbstractParent extends AbstractGrandfather {
protected AbstractParent(String name){
super();
list.add(name);
}
public class Child extends AbstractParent {
public Child(String fatherName, String childName){
super(fatherName);
list.add(childName);
}
public String getGrandFatherName(){
return "Samuel";
}
}
This is what i tried to do in Python:
import abc
from abc import ABCMeta, abstractmethod
class AbstractGrandFather(object):
__metaclass__ = ABCMeta
@abc.abstractmethod
def __init__(self):
list = [self.get_command_name(self)]
@abc.abstractmethod
def get_command_name(self):
pass
@property
def get_list(self):
return self.list
class AbstractParent(AbstractGrandFather):
__metaclass__ = ABCMeta
@abc.abstractmethod
def __init__(self, name):
self.list = super.get_list.append(name)
@abc.abstractmethod
def get_command_name(self):
pass
class Child(AbstractParent):
def get_command_name(self):
return "Samuel"
def __init__(self, father_name, child_name):
self.list = super(father_name).get_list.append(child_name)
x = Child("Dan," "Ben")
but it doesn't work and i get an error :
Traceback (most recent call last):
File "Dummy.py", line 43, in <module>
x = Child("Dan," "Ben")
TypeError: __init__() takes exactly 3 arguments (2 given)
Am I on the right track ? will appreciate some help and guiding lines.
Thank you