[Tutor] Eek, help!

Liam Clarke cyresse at gmail.com
Sun Nov 7 09:21:40 CET 2004


Hi all, 

Jacob - this is anyKey()

def anyKey(prompt=None): 
    if prompt is None:
        prompt = "Press any key"    
    print prompt
    while not msvcrt.kbhit():  # kbhit() returns 1 (true) or 0
(false), true if any key is pressed
        pass
    return

But, it was as Danny said, my while loop was always true, which is
odd, because, I had copied this -

def readBook(book):
    import os
    filename = 'addbook.dat'
    if os.path.exists(filename):
       store = file(filename,'r')
       while store:
          name = store.readline().strip()
	  entry = store.readline().strip()
          book[name] = entry
    else:
        store = file(filename,'w') # create new empty file
    store.close()

from Alan Gauld's tutorial, and it works fine... so Liam == confused is True.

But thanks all round,

Liam Clarke


On Sat, 6 Nov 2004 20:29:25 -0500, Jacob S. <keridee at jayco.net> wrote:
> Okay,
>     Just a quick question. How did you define your function? What is pause?
> Is it a list or something that you have added attributes to? Or maybe a
> class?
> 
> Your function pause.getKey() might look this no doubt?
> 
> class pause:
>     def getKey():
>         raw_input()
> 
> Is that how it is? I'm just curious.
> Jacob Schmidt
> 
> 


-- 
'There is only one basic human right, and that is to do as you damn well please.
And with it comes the only basic human duty, to take the consequences.


More information about the Tutor mailing list