On Wed, Mar 11, 2015 at 10:08 AM, Ian D <dux...@hotmail.com> wrote: > Hi > > > > I have seen some examples that seem to use a tuple with a method called > index() > > > The original code I was looking at had this sort of thing: > > > > SENSORS = ('sensor1', 'sensor2') > > > SENSORS[0]
> pin_index = SENSORS.index("sensor1") > > > so the result is that pin_index the is equal to 0 > > > I then read that a Tuple has no attribute index on this site > http://www.diveintopython.net/native_data_types/tuples.html > > >>>> t.index("example") > Traceback (innermost last): File "<interactive input>", line 1, in ? > AttributeError: 'tuple' object has no attribute 'index' > > > > The example seems to work with 2.7 and 3.3 for me. > > > > > > But I don't find much documentation on indexing Tuples using this method. > > > > I am just wondering if there is more specific documentation on using Tuples > this way > https://docs.python.org/2/library/stdtypes.html#sequence-types-str-unicode-list-tuple-bytearray-buffer-xrange It wasn't around until 2.4 according to what I read somewhere > > > Thanks. > > > > I am using Python 2.7 at moment. > > > > > > > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor -- Joel Goldstick http://joelgoldstick.com _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor