I'm not supprised... and understand why it's happening. I'm asking how to get around it.<br><div><br></div><div>Basically i'm asking how to override, if i can, the `=`</div><div><br></div><div><br></div><div>
<div><br><div class="gmail_quote">On Thu, Oct 11, 2012 at 5:32 PM, Dave Angel <span dir="ltr"><<a href="mailto:d@davea.name" target="_blank">d@davea.name</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 10/11/2012 04:48 PM, Kevin Anthony wrote:<br>
> I have a class that contains a list of items<br>
> I can set items using __setitem__ but if i want to set the while list, i<br>
> changes the variable from a myclass to a list. How can i accomblish this<br>
> Example<br>
>>>> C = myclass()<br>
>>>> C[0] = 57<br>
>>>> type(C)<br>
> myclass<br>
>>>> C = [57,58,59,60]<br>
This creates a list, and binds the name that used to refer to the<br>
myclass to now refer to the list. The myclass object will go away,<br>
since there are no more refs to it.<br>
<br>
>>>> type(C)<br>
> list<br>
><br>
><br>
Why is that a surprise?<br>
<br>
As for how to add multiple items to the existing mylist, how about:<br>
<br>
for index, item in enumerate([57, 50, 59, 60]) :<br>
C[index] = item<br>
<br>
Alternatively, you could call one of the other methods in the class.<br>
But since you gave us no clues, I'm shouldn't guess what it was called.<br>
But if I were to make such a class, I might use slicing:<br>
C[:] = [57, 50, 59, 60]<br>
<br>
BTW, your naming capitalization is backwards. Class names should begin<br>
with a capital, Myclass. Instances should begin with lowercase -<br>
myinstance<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
<br>
DaveA<br>
<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>Thanks<br>Kevin Anthony<br><a href="http://www.NoSideRacing.com" target="_blank">www.NoSideRacing.com</a><div><br><div>Do you use Banshee?</div></div>
<div>Download the Community Extensions:</div><div><a href="http://banshee.fm/download/extensions/" target="_blank">http://banshee.fm/download/extensions/</a></div><br>
</div></div>