0

What is the basic concept behind doing -> None: in

class dog:
    def __init__(self) -> None:
         self.name = "legend"

Kindly explain simply but conceptually as I am a beginner. Explain?

DjaouadNM
  • 22,013
  • 4
  • 33
  • 55
  • It's my ignorance but I am new to computer programming so I get lost in dunders. It actually is the correct answer to my question but I can't understand it completely. – Utpal Mohane Jul 15 '22 at 16:32
  • It is a type hint (https://peps.python.org/pep-0484/). Python does not enforce these but they are helpful in reading and debugging code. In your example it is saying "this function will return None" aka do not expect a value to be returned. If it said "-> int" you would expect the function to return an int. You can also use them on parameters like "def find_city(name: str = 'John', age: int = 18) -> str: – mr_mooo_cow Jul 15 '22 at 17:38

0 Answers0