Re: [Tutor] time.sleep() error

2005-08-02 Thread geon




geon napsal(a):

  sunny sunny napsal(a):

  
  
Hi all,

I am using time.sleep to stop my program execution for some time. I
have imported time and am able to use it sucessfully in the main
program.

However if I use it in any function I get the following error:

the time.sleep(1) command generates this error :
TypeError : 'int' object is not callable 

 


  
  
Dont you actually have something like this?:

from time import *

# somewhere you use sleep like this
sleep=10

# and then
sleep(1)

# you get:
#sleep(1)
#TypeError: 'int' object is not callable

In this case you "overwrite" the original function sleep() with your/my
variable sleep
Solution: rename your/my variable sleep to f.e. notAwake=10 :-)

  

Solution2: do not use from time import *.  Prefer import time. Now you
know why :-)
Its not a waste of time still to rewrite you code in this way. 

-- 
geon




___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] time.sleep() error

2005-08-02 Thread geon
sunny sunny napsal(a):

>Hi all,
>
>I am using time.sleep to stop my program execution for some time. I
>have imported time and am able to use it sucessfully in the main
>program.
>
>However if I use it in any function I get the following error:
>
>the time.sleep(1) command generates this error :
>TypeError : 'int' object is not callable 
>
>  
>

Dont you actually have something like this?:

from time import *

# somewhere you use sleep like this
sleep=10

# and then
sleep(1)

# you get:
#sleep(1)
#TypeError: 'int' object is not callable

In this case you "overwrite" the original function sleep() with your/my
variable sleep
Solution: rename your/my variable sleep to f.e. notAwake=10 :-)

-- 
geon



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] time.sleep() error

2005-08-02 Thread sunny sunny
Some additional information:

I am calling this function from a thread and I get the error. 
However if I call the function from the main program it works fine. 

I am using thread.start_new_thread() to start the thread. 

Thanks.
Santosh.

On 8/2/05, sunny sunny <[EMAIL PROTECTED]> wrote:
> Hi all,
> 
> I am using time.sleep to stop my program execution for some time. I
> have imported time and am able to use it sucessfully in the main
> program.
> 
> However if I use it in any function I get the following error:
> 
> the time.sleep(1) command generates this error :
> TypeError : 'int' object is not callable
> 
> I have tried to add import time after the function definition, it
> still does not work. Please help.
> 
> Thanks.
> Santosh
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] time.sleep() error

2005-08-02 Thread Kent Johnson
sunny sunny wrote:
> Hi all,
> 
> I am using time.sleep to stop my program execution for some time. I
> have imported time and am able to use it sucessfully in the main
> program.
> 
> However if I use it in any function I get the following error:
> 
> the time.sleep(1) command generates this error :
> TypeError : 'int' object is not callable 
> 
> I have tried to add import time after the function definition, it
> still does not work. Please help.

It looks like somehow the name time.sleep has been bound to an integer. Please 
post the code and the full error trace.

Kent

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor