From: David H. <dav...@gm...> - 2006-05-30 20:04:52
|
Just a thought: would it be possible to overload the array __getitem__ method ? I can do it with lists, but not with arrays... For instance, class fortarray(list): def __getitem__(self, index): return list.__getitem__(self, index+5) and >>> l = fortarray() >>> l.append(1) >>> l[-5] 1 There is certainly a more elegant way to define the class with the starting index as an argument, but I didn't look into it. For arrays, this doesn't work out of the box, but I'd surprised if there was no way to tweak it to do the same. Good luck David 2006/5/30, Rick Muller <rm...@sa...>: > > Indeed I am. Thanks for the reply > On May 30, 2006, at 11:32 AM, Rob Hetland wrote: > > > > > I believe Rick is talking about negative indices (possible in > > FORTRAN), in which case the answer is no. > > > > -Rob > > > > On May 30, 2006, at 11:28 AM, Rick Muller wrote: > > > >> Is it possible to create arrays that run from, say -5:5, rather > >> than 0:11? Analogous to the Fortran "allocate(A(-5:5))" command? > >> I'm translating a F90 code to Python, and it would be easier to do > >> this than to use a python dictionary. > > > > ----- > > Rob Hetland, Assistant Professor > > Dept of Oceanography, Texas A&M University > > p: 979-458-0096, f: 979-845-6331 > > e: he...@ta..., w: http://pong.tamu.edu > > > > > > Rick Muller > rm...@sa... > > > > > > > ------------------------------------------------------- > All the advantages of Linux Managed Hosting--Without the Cost and Risk! > Fully trained technicians. The highest number of Red Hat certifications in > the hosting industry. Fanatical Support. Click to learn more > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642 > _______________________________________________ > Numpy-discussion mailing list > Num...@li... > https://lists.sourceforge.net/lists/listinfo/numpy-discussion > |