+ 2

File operations in code-playground possible?

Hi @ all, I have 2 separate files in code playground which I startet one after the other: . # file1.py with open("info.txt", "w") as fh: word = "How much is the fish?" x = fh.write(word) print(x) . #file2.py with open("info.txt", "r") as fh: word = fh.readlines() print(word) . When running file2.py I get a "file not exist" error. Could You please explain the reason to me? . Many thanks in advance

26th Jan 2018, 9:28 PM
Jan Markus
6 odpowiedzi
+ 2
Yeah it doesn’t work in code playground I’m pretty sure, you have to download Python IDLE
26th Jan 2018, 9:44 PM
Ole113
Ole113 - avatar
+ 4
Hmm... perhaps it is still possible to somehow dig into your file if you save it as a code and link through code.sololearn.com... download it, save it as a file and exec() it. Unless they have the "access denied" policy there ;)
26th Jan 2018, 10:15 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 2
Hi Ole, thank You for Your answer. I have Python IDLE on my computer and there it works without problems, but I just wanted to try whether CodePlayground is capable of this task, but, regarding to Your response, it seems to be not working on the SL-server.
26th Jan 2018, 9:50 PM
Jan Markus
+ 2
If you first *create* or *download and save* the file, you can operate on it(even run it if it is a script!) in the split-second of the remote Python machine's run. Take a look: https://code.sololearn.com/c5f76DBYhYSO/?ref=app
26th Jan 2018, 9:59 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 1
Hi Kuba, thanks for Your response. :-) That means, what I wanted to do is only possible for a very short timespan. What I wanted to test was, whether I could write data to a file on SoloLearn, and come back to it days or months later, but this seems to be not possible.
26th Jan 2018, 10:09 PM
Jan Markus