my own type in C, sequence protocol

Torsten Mohr tmohr at
Thu Sep 9 22:21:12 CEST 2004


>> Now that i have implemented the sequence protocol, what
>> can i do with it, can't i assign values like above somehow?
> Nope.  The expression [1, 2, 3] evaluates to a list,
> as in listobject.  m = [1, 2, 3] binds the name "m"
> to this object.  Its prior binding to your myType()
> instance doesn't matter.  If you're new to Python, it's
> lucky you ran into this so early, because this business
> about names and objects is an important difference between
> Python and, for example, C++.

thanks for that explanation.  From the error messages i
got i already thought of something like this.  But still
i'm confused, what is the advantage to implement the
sequence protocol for my type then?

The type that i implemented is a "CAN message", don't know
if this means something to you, it is a communication message
with 0 to 8 bytes content.  To access this content i thought
there would be an advantage in implementing the sequence
protocol.  What is the advantage then?

Best regards,

More information about the Python-list mailing list