updade from Atlas repo
This commit is contained in:
23
25-class-metaprog/checked/initsub/checked_demo.py
Executable file
23
25-class-metaprog/checked/initsub/checked_demo.py
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from checkedlib import Checked
|
||||
|
||||
class Movie(Checked):
|
||||
title: str
|
||||
year: int
|
||||
box_office: float
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
movie = Movie(title='The Godfather', year=1972, box_office=137)
|
||||
print(movie.title)
|
||||
print(movie)
|
||||
try:
|
||||
# remove the "type: ignore" comment to see Mypy error
|
||||
movie.year = 'MCMLXXII' # type: ignore
|
||||
except TypeError as e:
|
||||
print(e)
|
||||
try:
|
||||
blockbuster = Movie(title='Avatar', year=2009, box_office='billions')
|
||||
except TypeError as e:
|
||||
print(e)
|
||||
Reference in New Issue
Block a user