[Tutor] Python Error Message

Alan Gauld alan.gauld at yahoo.co.uk
Wed Jan 27 04:07:11 EST 2021


On 27/01/2021 03:36, Nirel Leitman via Tutor wrote:
> Thank you.  And yes, degrees.py is also a folder name along with small. 

In that case you are trying to get Python to execute a folder, which
won't work.

>  I was told that file names should have .py at the end of it so 
> that Python can recognize it.

Its so that the OS can recognize it as a python file and call
python when you double click on it. Python is happy to execute
the file even without the .py. But it is only files,
not folders, that need the .py extension.

So you need to rename your folder to degrees.
Then inside the degrees folder you need to store your
degrees.py file.
You also need to create another folder inside degrees
called small. I'm not sure what you store in small,
presumably some kind of data file?

Also given your code defaults to large there should
also be a folder called large with another(bigger?)
data file contained in it?

> I went ahead and changed the folder back to just degrees 
> before receiving this email.  

OK so just to be clear. Your path to your python file is now

C:\Users\leitm\Desktop\AI\degrees\degrees.py

Is that correct?

And the path to your data is:

C:\Users\leitm\Desktop\AI\degrees\small

Is that correct?

> I will try again tomorrow with the forward slashing to see if that helps at all. 

I've no idea if that will make a difference,
its been a while since I used Python on windows.

> Also, how to do I create a directory for the small folder?

Now you have confused me!
A directory and a folder are the same thing.
You would normally just use your file manager tool
to create a folder. (You can of course use the
command line or even do it from python, but for
this purpose using file manager is simpler)

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list