Re: [Tutor] reading files in Python 3

2017-03-31 Thread eryk sun
On Thu, Mar 30, 2017 at 8:45 PM, Mats Wichmann wrote: > Yeah, fun. You need to escape the \ that the idiot MS-DOS people chose > for the file path separator. Because \ is treated as an escape character. The COMMAND.COM shell inherited command-line switches (options) that use slash from TOPS-10 b

Re: [Tutor] reading files in Python 3

2017-03-31 Thread Mats Wichmann
On 03/31/2017 09:44 AM, Alex Kleider wrote: > On 2017-03-30 13:45, Mats Wichmann wrote: > >> >> Yeah, fun. You need to escape the \ that the idiot MS-DOS people chose >> for the file path separator. > > I also believe that the "MS-DOS people" are making a poor choice > but to call them idiots is

Re: [Tutor] reading files in Python 3

2017-03-31 Thread Alex Kleider
On 2017-03-30 13:45, Mats Wichmann wrote: Yeah, fun. You need to escape the \ that the idiot MS-DOS people chose for the file path separator. I also believe that the "MS-DOS people" are making a poor choice but to call them idiots is perhaps a bit strong. Remember that for many the use of Mi

Re: [Tutor] reading files in Python 3

2017-03-31 Thread Mats Wichmann
On 03/30/2017 11:02 AM, Rafael Knuth wrote: > I can read files like this (relative path): > > with open("Testfile_B.txt") as file_object: > contents = file_object.read() > print(contents) > > But how do I read files if I want to specify the location (absolute path): > > file_path = "C:\U

Re: [Tutor] reading files in Python 3

2017-03-30 Thread eryk sun
On Thu, Mar 30, 2017 at 8:47 PM, Zachary Ware wrote: > In this case, the problem is the bogus Unicode escape that you > inadvertently included in your path: `\Us...`. To fix it, either use a > 'raw' string (`r"C:\Users\..."`) or use forward slashes rather than > backslashes, which Windows is happ

Re: [Tutor] reading files in Python 3

2017-03-30 Thread Zachary Ware
On Mar 30, 2017 15:07, "Rafael Knuth" wrote: I can read files like this (relative path): with open("Testfile_B.txt") as file_object: contents = file_object.read() print(contents) But how do I read files if I want to specify the location (absolute path): file_path = "C:\Users\Rafael\Tes

[Tutor] reading files in Python 3

2017-03-30 Thread Rafael Knuth
I can read files like this (relative path): with open("Testfile_B.txt") as file_object: contents = file_object.read() print(contents) But how do I read files if I want to specify the location (absolute path): file_path = "C:\Users\Rafael\Testfile.txt" with open(file_path) as file_object: