tag:blogger.com,1999:blog-18677687.post5327289902666573929..comments2024-03-27T15:13:24.764-04:00Comments on Computer Science Teacher: What’s In A Name?Alfred Thompsonhttp://www.blogger.com/profile/05575057876858763822noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-18677687.post-57977631784934281022019-11-26T12:55:51.140-05:002019-11-26T12:55:51.140-05:00It students did not make stupid errors what would ...It students did not make stupid errors what would we teachers do for fun? Make our own stupid errors? I am very experienced at that.Garthnoreply@blogger.comtag:blogger.com,1999:blog-18677687.post-59048063001857958912019-11-26T05:26:13.514-05:002019-11-26T05:26:13.514-05:00Well, some tools that try to get more meaningful m...Well, some tools that try to get more meaningful messages exits. For example - Thonny (IDE for Python) has "Assistant". For code<br /><br />x = 1<br />y = y + 1<br /><br />assistant "writes" (it is more nicely formatted...):<br /><br />NameError: name 'y' is not defined<br />a.py, line 2<br />Python doesn't know what y stands for.<br /><br />Did you actually mean string (text)?<br />If you didn't mean a variable but literal text "y", then surround it with quotes.<br /><br />Did you forget to import it?<br />Some functions/variables need to be imported before they can be used.<br /><br />Has Python executed the definition?<br />Don't forget that name becomes defined when corresponding definition ('=', 'def' or 'import') gets executed. If the definition comes later in code or is inside an if-statement, Python may not have executed it (yet).<br />Make sure Python arrives to the definition before it arrives to this line. When in doubt, use the debugger.<br /><br /><br />Warnings<br />May help you find the cause of the error.<br /><br /><br />a.py<br />Line 2 : Using variable 'y' before assignment<br />It looks like the local variable is accessed before its assignment.<br /><br />Matija Lokarhttps://www.blogger.com/profile/17104969054503615781noreply@blogger.com