Doesn't know what it wants

marek.rocki at wp.pl marek.rocki at wp.pl
Sat Jan 26 08:20:15 EST 2008


> class vec2d(ctypes.Structure):
>     """2d vector class, supports vector and scalar operators,
>        and also provides a bunch of high level functions
>        """
>     __slots__ = ['x', 'y']
>
>     def __init__(self, x_or_pair, y = None):
>
>         if y == None:
>             self.x = x_or_pair[0]
>             self.y = x_or_pair[1]
>         else:
>             self.x = x_or_pair
>             self.y = y

I may be way off here, but why does vec2d inherit from
ctypes.Structure if it doesn't observe the protocol for Structures
(they're supposed to have _fields_, not __slots__)?



More information about the Python-list mailing list