0

I have written the code using Visual Studio code

from datetime import date

Title = 'Actividad #$'
Complexity = 0
Time = 5 #cantidad en dias

class Activitie(Title,Complexity,Time):
    """Log your activity with this class"""

    Title = 'Actividad #$'
    Complexity = 0
    Time = 5 #cantidad en dias

And it shows

Inheriting 'Time', which is not a class.
Inheriting 'Complexity', which is not a class.
Inheriting 'Title', which is not a class.

and ...

TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

Thank you for any solution

Mahendra Gunawardena
  • 1,956
  • 5
  • 26
  • 45
Dr.Omar
  • 5
  • 1
  • 3
  • 2
    Title is a string, complexity and time are both integers. When you put them in in your class declaration, python expects them to be classes you are inheriting, which they are not. Therefore you are getting an error. 90% of the time error messages very clearly show the issue, but people dont pay attention – Ahmet May 25 '20 at 20:12
  • 1
    The error is telling you exactly the problem, `Title`, `Complexity`, and `Time` **are not class objects**, so you can't inherit from them in a class definition statement. I don't know what you were *intending* to do. I suggest [reading the official documentation/tutorial](https://docs.python.org/3/tutorial/classes.html) – juanpa.arrivillaga May 25 '20 at 20:12
  • 1
    I don't understand what you expect `class Activitie(Title,Complexity,Time)` to do. Were you perhaps looking to implement the `__init__` method? I think you need to pay more attention to whatever you're using to learn Python; Stack Overflow is not a good place to learn the fundamentals. – Karl Knechtel May 25 '20 at 20:16

1 Answers1

1

Looks like you want to define the class object constructor, but you've accidentally done it using Python's class inheritance syntax.

Here's how to define a class and its object constructor:

class Activitie:
    def __init__(self, Title, Complexity, Time):
    """Log your activity with this class"""

        self.Title = Title
        self.Complexity = Complexity
        self.Time = Time 

Your getting this Inheritance error because the syntax for declaring inheritance in Python looks like this:

SubClass(ParentClassA, ParentClassB, ParentClassC):
captnsupremo
  • 689
  • 5
  • 11