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:

You need to base myclass on a list if I understand your question.

class myclass(list):
     def __init__(self, *items):
         # change items if needed
         # initate other attributes if needed
         list.__init__(self, *items)

Then the line below should work.  Of course it won't do much with out 
something in it.  ;-)

> 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?
> 
> James

A dictionary would be pretty much the same except subclassed from a 
dictionary of course.

Cheers,
    Ron



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to