MCPcopy Create free account
hub / github.com/dabeaz-course/python-mastery / __init__

Method __init__

Solutions/6_1/structure.py:5–9  ·  view source on GitHub ↗
(self, *args)

Source from the content-addressed store, hash-verified

3class Structure:
4 _fields = ()
5 def __init__(self, *args):
6 if len(args) != len(self._fields):
7 raise TypeError('Expected %d arguments' % len(self._fields))
8 for name, val in zip(self._fields, args):
9 setattr(self, name, val)
10
11 def __setattr__(self, name, value):
12 if name.startswith('_') or name in self._fields:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected