James Stroud wrote:
> Hello All,
>
> How does one make an arbitrary class (e.g. class myclass(object)) behave like
> a list in method calls with the "*something" operator? What I mean is:
>
> myobj = myclass()
>
> doit(*myobj)
>
> I've looked at getitem, getslice, and iter. What is it if not one of these?
>
> And, how about the "**something" operator?
Avoiding magic at the expense of terseness, I would do something like
the following:
class myclass(object):
def totuple(self):
...
def todict(self):
...
myargs = myclass()
mykwds = myclass()
doit(*myargs.totuple(), **mykwds.todict())
--
Robert Kern
[EMAIL PROTECTED]
"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
--
http://mail.python.org/mailman/listinfo/python-list