[Tutor] What is wrong with my Python program that causes it to run but not give results?

Ed Troy etroy at aeroconsult.com
Wed Oct 26 11:45:32 EDT 2016


I found the problem. Originally, I was getting errors that were related 
to formatting, apparently. It looked fine to me, but because I had 
copied it from the web, there were, apparently, hidden characters. In an 
effort to get rid of errors, I was eliminating some lines. I finally 
added a line,
# -#- coding: utf-8 -*-
near the beginning of the file. This is when I got to where I was with 
it seeming to run if I started the command line with python3 but getting 
errors if I started with python. I was pretty sure I had all of the 
required modules installed.

But then, when instructed to add some lines at the end for debugging, I 
found that I had accidentally removed two lines at the end and forgot to 
add them back in.

They were:
if __name__=="__main__":
     main()

Once I added them, it runs fine whether I say python LED_model_utf8.py 
LED_IV.txt     or python3 LED_model_utf8.py LED_IV.txt

Thanks to everyone. Sorry for the mistake on my part. I think that if I 
had added the # -#- coding: utf-8 -*- right from the start, the problem 
never would have happened.
Ed

On 10/26/2016 10:18 AM, Felix Dietrich wrote:
>> Alan Gauld via Tutor <tutor at python.org> writes:
>>> On 26/10/16 04:19, Ed Troy wrote:
>>> Would it be a help if I actually list the python program that I am
>>> trying to run?
>> Yes. I'm assuming you just cut n paste the code from the web site but
>> something could have gone wrong with the formatting and Python is
>> sensitive to that, so seeing your actual code would be a good idea.
> Could you also provide a small set of sample data that fails, maybe
>
>      $ head LED_IV.txt > sample.txt
>
> will be enough.
>
> --
> Felix Dietrich
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
>



More information about the Tutor mailing list