[Tutor] mscvrt module question

Alan G alan.gauld at freenet.co.uk
Thu Jun 30 22:21:52 CEST 2005


>    File "C:\Documents and Settings\Tom C\My Documents\Python
projects -
> Toms\quiz\quiz.py", line 13, in __main__
>      KeyIn = getch()
> NameError: name 'getch' is not defined
>

Have you actually imported the msvcrt module?
And if so did you import kbhit and getch since you aren't prefixing
the names with the module?

Normally I'd expect to see

Keyln = msvcrt.getch()

> a=kbhit()
>
> Traceback (most recent call last):
> [snip]
> File "<console>", line 0, in __main__
> NameError: name 'defined' is not defined

That looks more like you tried to execute an error message by mistake!

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld



More information about the Tutor mailing list