See It to Believe It: PyScripter 2.7 help


#1

Hey! How is everyone doing? I'm doing great! I'm almost done the course!

So, I use PyScripter 2.7 as my IDE while I'm working on the exercises (very helpful!) and I'm confused how to file Input/Output with it.
Anyone have helpful tips?
I ran the code and nothing happens. Is there something I have to set up or configure for output to txt file to work?

Thanks!


my_list = [i**2 for i in range(1,11)]
# Generates a list of squares of the numbers 1 - 10

f = open("output.txt", "w")

for item in my_list:
    f.write(str(item) + "\n")

f.close()


#2

Hi @aleksyochev,

If you look in the same folder (or directory) where this Python program is stored after you run it, do you not find a file named output.txt?

If you cannot find it, try running this ...

# Create and write the file
f = open("text.txt", "w+")
f.write("My content appears on the screen,\n")
f.write("therefore,\n")
f.write("I must exist!\n")
f.close()
# Read the file
my_file = open("text.txt", "r")
print(my_file.readline())
print(my_file.readline())
print(my_file.readline())
my_file.close()

If the lines of output get displayed in the terminal or console, then a text.txt file must have been created, written, and read. You can find out where your Python code is stored, and look for the text.txt file there.


#3

Hi @appylpye !
o.k, I looked and yes! I found it. I must have thought that the .txt file would pop open automatically! I'll have to go look to see how I can set up my PyScripter IDE so I can see the file when I create it! I think it's actually an easy reset. I may have changed the settings earlier to hide the file directory with folders.

Thanks so much for the helpful hint!

I'll run your code to see it working! More code to try is always welcome!

Well_Met!

Hahaha! just ran it. it works! Very clever! Thanks! My confusion has been lifted!

Thanks!


#4