This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import namedtuple | |
Point_type = namedtuple('Point', ('x', 'y')) | |
point_instance = Point_type(1, 10) | |
print(type(Point_type)) | |
print(type(point_instance)) | |
print(point_instance.__class__.__name__) | |
print(isinstance(point_instance, Point_type)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# works on Python 3 | |
def check_argument_type(func): | |
def wrapper(*args): | |
if ( | |
not hasattr(func, '__annotations__') or | |
len(func.__annotations__) == 0 | |
): | |
return func(*args) |
NewerOlder