jstroud at mbi.ucla.edu
Wed Dec 24 09:48:14 CET 2008
Steven Woody wrote:
> In the book Python Essential Reference, Chapter 3, when talking about
> extended slicing, it gives an example: a = m[0:10, 3:20]. But I
> don't understand how the 'm' was defined. What should it looks like?
m could be an instance of the Krayzee class.
py> class Krayzee(object):
... def __getitem__(self, i):
... r = ['WTF?' for j in i]
... r = 'WTF?'
... return r
py> m = Krayzee()
py> m[1:2:3, 4:5:6]
py> m['your moms']
['WTF?', 'WTF?', 'WTF?', 'WTF?', 'WTF?', 'WTF?', 'WTF?', 'WTF?', 'WTF?']
UCLA-DOE Institute for Genomics and Proteomics
Los Angeles, CA 90095
More information about the Python-list