Having error while declaring the variable. Kindly help please

CODE:
class animal:

_age_ = 0
_name_ = None

@staticmethod

def _init_(self):
    self._name_ = None
    self._age_ = None

def get_age(self):
    return self._age_

def get_name(self):
    return self._name_

obj = animal()
obj.get_age()
obj.get_name()

class lion(animal):
def init(self, L1, age, Lion, Roar):
super().init(L1, 5)
self.name = L1
self.age = age
self.type = Lion
self.sound = Roar

def p1(self):
  print("The name of Lion is " + staticmethod(self._name_))
  print("The age of the Lion is " + staticmethod(self._age_))
  print("It is type of " + staticmethod(self._type_))
  print("It makes a sound of " + staticmethod(self._sound_))        

class chicken(animal):
def init(self, C1, age, Chicken, Cluck):
super().init(C1, 1)
self.name = C1
self.age = age
self.type = Chicken
self.sound = Cluck

def p2(self):
  print("The name of Chicken is " + staticmethod(self._name_))
  print("The age of the chicken is " + staticmethod(self._age_))
  print("It is type of " + staticmethod(self._type_))
  print("It makes a sound of " + staticmethod(self._sound_))

  from types import T1

from typing import TypeVar, Generic

class animal():
age = 0
name = None

def _init_(self, name, age):
    self._name_ = name
    self._age_ = age

def get_age(self):
    return self._age_

def get_name(self):
    return self._name_

class lion():
def init(self, name, age):
super().init(name, age)
self.name = name
self.age = age
self.type = “lion”
self.sound = “roar”

def get_type(self):
   return self._type_

def get_sound(self):
   return self._sound_

class chicken():
def init(self, name, age):
super().init(name, age)
self.name = name
self.age = age
self.type = “chicken”
self.sound = “cluck”

def get_type(self):
    return self._type_

def get_sound(self):
    return self._sound_ 

‘’'class animal_cage (Generic[T]):
@staticmethod

for cage = []

def cage_animal(self, value: T1):
    cage.push(1)

def list_animals(self):
    print("Animals in cage: ")
    for i in range(len(cage)):
        print(cage[i].get_name())

‘’’
class animal_cage (Generic[T1]):
@staticmethod

#for cage = []

def cage_animal(self, value : T1):
    cage.push(1)

def list_animals(self):
    print("Animals in cage: ")
    for i in range(len(cage)):
        print(cage[i].get_name())

ERROR:

NameError Traceback (most recent call last)
in
106 print(cage[i].get_name())
107 ‘’’
→ 108 class animal_cage (Generic[T1]):
109 @staticmethod
110

NameError: name ‘T1’ is not defined

To prevent the code from being mangled by the markdown formatting please enclose it between triple backticks like this:

```
Here will be your code.
```

If you are not able to find the backtick on your keyboard, copy it from my post.


You are neither declaring nor assigning T1. You have only from types import T1 in the scope of p2() not in the global scope where you need T1. Anyway types is a module in the standard library which does not contain the T1 identifier.

If you have your module of that name you should chose a different name to avoid shadowing the standard library module.

You probably want to define T1 as a TypeVar:


Also it is weird that your code does not use type annotations except the single - relatively complex concept: generics. Why? You should start from the simplest concepts in type annotations.