ex17 created, answered question added
This commit is contained in:
parent
67f6d00357
commit
f9f6b41ce1
2 changed files with 48 additions and 0 deletions
24
balazs/python-the-hard-way/ex17/notes.org
Normal file
24
balazs/python-the-hard-way/ex17/notes.org
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
* Questions
|
||||||
|
|
||||||
|
** Why does Opening and Reading the file is done in 2 steps? What's the difference?
|
||||||
|
in_file = open(from_file)
|
||||||
|
indata = in_file.read()
|
||||||
|
|
||||||
|
"Opening" a file doesn't actually bring any of the data from the file into your program. It just prepares the file for reading (or writing), so when your program is ready to read the contents of the file it can do so right away.
|
||||||
|
*** Source:
|
||||||
|
https://stackoverflow.com/questions/20308998/what-is-the-difference-between-opening-and-reading-a-file-in-python
|
||||||
|
|
||||||
|
** What does 'w' mean? (from ex16)
|
||||||
|
target = open(filename, 'w')
|
||||||
|
|
||||||
|
It's a string with a character in it for the kind of mode for the file.
|
||||||
|
|
||||||
|
'w' = write
|
||||||
|
'r' = read
|
||||||
|
'a' = append
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
* Note
|
||||||
|
|
||||||
|
" character messes up the copy in org or emacs
|
24
balazs/python-the-hard-way/ex17/notes.org~
Normal file
24
balazs/python-the-hard-way/ex17/notes.org~
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
* Questions
|
||||||
|
|
||||||
|
** Why does Opening and Reading the file is done in 2 steps? What's the difference?
|
||||||
|
in_file = open(from_file)
|
||||||
|
indata = in_file.read()
|
||||||
|
|
||||||
|
"Opening" a file doesn't actually bring any of the data from the file into your program. It just prepares the file for reading (or writing), so when your program is ready to read the contents of the file it can do so right away.
|
||||||
|
*** Source:
|
||||||
|
https://stackoverflow.com/questions/20308998/what-is-the-difference-between-opening-and-reading-a-file-in-python
|
||||||
|
|
||||||
|
** What does 'w' mean? (from ex14)
|
||||||
|
target = open(filename, 'w')
|
||||||
|
|
||||||
|
It's a string with a character in it for the kind of mode for the file.
|
||||||
|
|
||||||
|
'w' = write
|
||||||
|
'r' = read
|
||||||
|
'a' = append
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
* Note
|
||||||
|
|
||||||
|
" character messes up the copy in org or emacs
|
Loading…
Reference in a new issue