Terry Reedy wrote:
In 3.x, you would write __setitem__ to recognize that the 'key' is a
slice object rather than an int and act accordingly. (In 2.x, you would
write __setslice__.)
I'm not sure how far back it goes, but at least from 2.4 forward
__setitem__ works with slices just fine.
Ethan Furman wrote:
Terry Reedy wrote:
In 3.x, you would write __setitem__ to recognize that the 'key' is a
slice object rather than an int and act accordingly. (In 2.x, you would
write __setslice__.)
I'm not sure how far back it goes, but at least from 2.4 forward
__setitem__ works with
I have a class that contains a list of items
I can set items using __setitem__ but if i want to set the while list, i
changes the variable from a myclass to a list. How can i accomblish this
Example
C = myclass()
C[0] = 57
type(C)
myclass
C = [57,58,59,60]
type(C)
list
--
On 10/11/2012 04:48 PM, Kevin Anthony wrote:
I have a class that contains a list of items
I can set items using __setitem__ but if i want to set the while list, i
changes the variable from a myclass to a list. How can i accomblish this
Example
C = myclass()
C[0] = 57
type(C)
myclass
C =
I'm not supprised... and understand why it's happening. I'm asking how to
get around it.
Basically i'm asking how to override, if i can, the `=`
On Thu, Oct 11, 2012 at 5:32 PM, Dave Angel d...@davea.name wrote:
On 10/11/2012 04:48 PM, Kevin Anthony wrote:
I have a class that contains a
On Thu, Oct 11, 2012 at 4:13 PM, Kevin Anthony
kevin.s.anth...@gmail.com wrote:
I'm not supprised... and understand why it's happening. I'm asking how to
get around it.
Basically i'm asking how to override, if i can, the `=`
You cannot override assignment of local variables. To get around
On 10/11/2012 5:32 PM, Dave Angel wrote:
Alternatively, you could call one of the other methods in the class.
But since you gave us no clues, I'm shouldn't guess what it was called.
But if I were to make such a class, I might use slicing:
C[:] = [57, 50, 59, 60]
In 3.x, you would write
Kevin Anthony wrote:
I'm not supprised... and understand why it's happening. I'm asking how
to get around it.
I don't think you do understand what's happening.
What's happening is the basic application of name binding in Python:
-- C = anything
whatever C was bound to before, it no longer