Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code error on page "10.7. Recipe for Reading and Processing a File" #236

Open
paccattam opened this issue Aug 18, 2019 · 7 comments
Open

Comments

@paccattam
Copy link

The following code snippet given in the end of the text @ the link given below should have mentioned fire opbject reference instead of "lines"
https://fopp.umsi.education/runestone/static/fopp/Files/FilesRecipe.html

fname = "yourfile.txt"
with open(fname, 'r') as fileref: # step 1
for lin in lines: # step 2
## some code that reference the variable lin
#some other code not relying on fileref # step 3

@bnmnetp bnmnetp transferred this issue from RunestoneInteractive/RunestoneComponents Aug 19, 2019
@EzraSkwarka
Copy link
Contributor

@paccattam I'm not entirely sure what you are asking us to do, can you clarify a little bit?
Are you saying the 2nd snippet should be:
fname = "yourfile.txt"
with open(fname, 'r') as fileref: # step 1
for lin in fileref.readlines(): # step 2
## some code that reference the variable lin
#some other code not relying on fileref # step 3

@bnmnetp
Copy link
Member

bnmnetp commented Oct 2, 2019

The example should be:

with open(fname, 'r') as fileref:
    for line in fileref:
        ## some code that uses line as the current line of the file
        ## some more code

@bnmnetp
Copy link
Member

bnmnetp commented Oct 2, 2019

fileref.readlines is not wrong its just not necessary.

@presnick
Copy link
Collaborator

presnick commented Oct 2, 2019

It should be lin rather than line, to be compatible with the previous example on the page.

@EzraSkwarka
Copy link
Contributor

Issued a pull request

@dbrucknr
Copy link
Contributor

dbrucknr commented Dec 1, 2019

Just checking in on this issue. It appears a fix has been initiated.
Can this issue/ticket be closed?

@bnmnetp
Copy link
Member

bnmnetp commented Dec 2, 2019

Still waiting for some changes to the PR, we can close as soon as the PR is accepted.

bnmnetp added a commit that referenced this issue Jun 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants