[Tutor] Variable and a raw string

Alessandro Caudilho caudilho at cock.li
Mon Jan 20 22:30:14 EST 2020


On Tue, 21 Jan 2020 10:15:16 +1300
David L Neil via Tutor <tutor at python.org> wrote:

> Did you re-type the code or did you copy-paste it from the editor into 
> this email msg???
> (the mixture of quotation-marks/double-quotes and 
> apostrophe/single-quote in the err.msg, indicates that the above code is 
> NOT the original)
> 
> 1 if the code is being run (by "user") from his/her home-directory (ie 
> /home/user) then all that may be omitted from the open()
> 
> 2 if your intent is to separate each US State into its own directory, 
> then would "...US/Colorado..." make for a better stepwise-refinement?
> 
> 3 otherwise if the "us" part is merely a label, perhaps to distinguish 
> from some "colorado" in another country, then please see previous responses.
> 
> 4 Please review open-append in 
> https://docs.python.org/3/library/functions.html?highlight=open#open 
> (see also "absolute" and "relative", per (1) above). What happens if one 
> opens a file in a directory which does not (yet) exist? How does this 
> differ from attempting to open a file which does not exist (read) or 
> does not yet exist (append)? (experiment in the Python REPL)

Thanks David! I copy-pasted the code from my editor.

This code is a part of the one that uses weather API. When I call, it returns me number of bulk values with current weather forecasts. One of values is a state (e.g. 'colorado/us'). I know that I can`t create file because of '/' in 'colorado/us'. But maybe is there some way to avoid removing or replacing slash in 'state'?

My fault - I should give more information on this in my first message


-- 
Alessandro Caudilho <caudilho at cock.li>


More information about the Tutor mailing list