Y
youhvee
Hi,
I'm trying to create a new class of list that has periodic boundary
conditions.
Here's what I have so far:
class wrappedList(list):
def __getitem__(self, p):
return list.__getitem__(self, p%len(self))
def __setitem__(self, p, v):
list.__setitem__(self, p%len(self), v)
But I would also like to make slices. For instance I would like
I can do it by copying, but I want to return a view to the original
data, and I have no idea where to start. It seems that the slice needs
to retain some knowledge of the list from which it derived. i.e. it
needs to know that it is a slice. Any ideas on how I can extend this
to allow views?
Thanks for any help.
-AM
I'm trying to create a new class of list that has periodic boundary
conditions.
Here's what I have so far:
class wrappedList(list):
def __getitem__(self, p):
return list.__getitem__(self, p%len(self))
def __setitem__(self, p, v):
list.__setitem__(self, p%len(self), v)
1a=wrappedList(range(10))
a[1] 1
a[11]
But I would also like to make slices. For instance I would like
[8, 9, 0]
I can do it by copying, but I want to return a view to the original
data, and I have no idea where to start. It seems that the slice needs
to retain some knowledge of the list from which it derived. i.e. it
needs to know that it is a slice. Any ideas on how I can extend this
to allow views?
Thanks for any help.
-AM