Skip to content

Instantly share code, notes, and snippets.

@hannal
hannal / namedtuple.py
Last active August 29, 2015 14:24
namedtuple typename
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))
# 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)