rrr at ronadam.com
Tue Nov 8 05:29:28 CET 2005
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.
def __init__(self, *items):
# change items if needed
# initate other attributes if needed
Then the line below should work. Of course it won't do much with out
something in it. ;-)
> myobj = myclass()
> I've looked at getitem, getslice, and iter. What is it if not one of these?
> And, how about the "**something" operator?
A dictionary would be pretty much the same except subclassed from a
dictionary of course.
More information about the Python-list