I am little experimenting with Python type annotation today. I wrote a simple 
class as below:

>>> from datetime import date
>>> class Person:
...     dob: date
...     def __init__(self, dob):
...             self.dob = dob
... 
>>> Person(11)
<__main__.Person object at 0x10e078128>
>>> p = Person(11)
>>> p.dob
11

Although I marked dob as date type, why am I able to assign it an int? So my 
question how does type annotation helps, when should we use them and what 
advantages it brings?

Thanks,

Arup Rakshit
a...@zeit.io



_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to