Re: [Tutor] Enumerate vs DictReader object manipulation:

2016-02-04 Thread Oscar Benjamin
On 4 February 2016 at 06:45, Matt Williams wrote: > > Just as a note - you are not the only person caught out by this - it is a > very common slip. > > I wonder whether it would be worth adding a more explicit line about this > in the Python Docs? Where in the docs

Re: [Tutor] Enumerate vs DictReader object manipulation:

2016-02-04 Thread Oscar Benjamin
On 4 February 2016 at 03:21, Ben Finney wrote: > Alex Kleider writes: > >> How does a dict fit into this scheme? >> Is it a sequence? > > No, a dict is not a sequence. But it is a container: all its items > remain available and can be retrieved

Re: [Tutor] Enumerate vs DictReader object manipulation:

2016-02-04 Thread Alex Kleider
On 2016-02-04 01:46, Oscar Benjamin wrote: You can see an explanation of the different collection terminology here: https://docs.python.org/2/library/collections.html#collections-abstract-base-classes A dict is a Mapping and a set is a Set. Both also comes under the categories Sized,

Re: [Tutor] Enumerate vs DictReader object manipulation:

2016-02-04 Thread Matt Williams
Just as a note - you are not the only person caught out by this - it is a very common slip. I wonder whether it would be worth adding a more explicit line about this in the Python Docs? Matt On Wed, 3 Feb 2016 16:13 Ek Esawi wrote: > Hi All > > > > > > I have a code that

Re: [Tutor] Enumerate vs DictReader object manipulation:

2016-02-03 Thread Ben Finney
Ek Esawi writes: > I have a code that reads a csv file via DictReader. I ran into a peculiar > problem. The python interpreter ignores the 2nd code. That is if I put the > reader iterator 1st, like the code below, the enumerate code is ignored; if > I put the enumerate code

Re: [Tutor] Enumerate vs DictReader object manipulation:

2016-02-03 Thread Ek Esawi
Thank you all. The only reason i tried both ways is to experiment with Python. They made sense to me and thought why not try them both. And i am relatively new to Python. Thanks again--EKE ___ Tutor maillist - Tutor@python.org To unsubscribe or change

Re: [Tutor] Enumerate vs DictReader object manipulation:

2016-02-03 Thread Ben Finney
Alex Kleider writes: > How does a dict fit into this scheme? > Is it a sequence? No, a dict is not a sequence. But it is a container: all its items remain available and can be retrieved again and again, and you can interrogate whether a value is one of the items in that

Re: [Tutor] Enumerate vs DictReader object manipulation:

2016-02-03 Thread Alex Kleider
On 2016-02-03 13:24, Ben Finney wrote: You have discovered the difference between an iterable (an object you can iterate over with ‘for’), versus a sequence (an object whose items remain in place and can be iterated many times). Every sequence is an iterable, but not vice versa. File objects

Re: [Tutor] Enumerate vs DictReader object manipulation:

2016-02-03 Thread Alan Gauld
On 03/02/16 15:29, Ek Esawi wrote: > reader = csv.DictReader(MyFile) > > for row in reader: > list_values = list(row.values()) > print (list_values) > At this point the reader has reached the end of the file. > for i,j in enumerate(reader): > print(j) So

[Tutor] Enumerate vs DictReader object manipulation:

2016-02-03 Thread Ek Esawi
Hi All I have a code that reads a csv file via DictReader. I ran into a peculiar problem. The python interpreter ignores the 2nd code. That is if I put the reader iterator 1st, like the code below, the enumerate code is ignored; if I put the enumerate code 1st, the reader code is ignored. I

Re: [Tutor] Enumerate vs DictReader object manipulation:

2016-02-03 Thread Danny Yoo
> I have a code that reads a csv file via DictReader. I ran into a peculiar > problem. The python interpreter ignores the 2nd code. That is if I put the > reader iterator 1st, like the code below, the enumerate code is ignored; if > I put the enumerate code 1st, the reader code is ignored. I am