Creating a namedtuple object using only a subset of arguments passed
问题 I am pulling rows from a MySQL database as dictionaries (using SSDictCursor) and doing some processing, using the following approach: from collections import namedtuple class Foo(namedtuple('Foo', ['id', 'name', 'age'])): __slots__ = () def __init__(self, *args): super(Foo, self).__init__(self, *args) # ...some class methods below here class Bar(namedtuple('Bar', ['id', 'address', 'city', 'state']): __slots__ = () def __init__(self, *args): super(Bar, self).__init__(self, *args) # some class