bpo-45498: fix csv dictReader code example#28999
Closed
AkechiShiro wants to merge 1 commit into
Closed
Conversation
451f4a8 to
c987b7f
Compare
smontanaro
reviewed
Oct 16, 2021
smontanaro
left a comment
Contributor
There was a problem hiding this comment.
The current code looks fine to me. Here's a simple session:
>>> import csv
>>> with open('names.csv', newline='') as csvfile:
... reader = csv.DictReader(csvfile)
... for row in reader:
... print(row['first_name'], row['last_name'])
...
Eric Idle
John Cleese
>>> print(reader)
<csv.DictReader object at 0x7f06c1619dc0>
>>> print(row)
{'first_name': 'John', 'last_name': 'Cleese'}
Contributor
Author
|
Hi @smontanaro, could you explain to me why the |
Contributor
|
The |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes an example in the documentation.
Replacing
print(row)byprint(reader)inDictReaderfor thecsvlib.https://bugs.python.org/issue45498