On Sat, 3 Apr 2010 22:58:43 +0000 (UTC) kj <[email protected]> wrote:
> The best I have managed looks like this:
>
> class _Spam(object):
> def __init__(self, x, y, z):
> self.__dict__ = OrderedDict(())
> for p in inspect.getargspec(_Spam.__init__).args[1:]:
> self.__dict__[p] = locals()[p]
>
> def __iter__(self):
> return iter(self.__dict__.values())
Looks like you're trying to be lazy by doing extra hard work. Anything
wrong with this (?):
class Spam(object):
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
self.arguments = (x, y, z)
def __iter__(self):
return iter(self.arguments) # iter(...) kinda optional
With what little I know about your use case, that's how I would do it.
/W
--
INVALID? DE!
--
http://mail.python.org/mailman/listinfo/python-list