You are using the same name time for both the time module and the argument of your function. However, if you want to do this you don't need to define a new function yourself. Python supports reassigning functions to different variable names, so you could just do wait = time.sleep (note its important we didn't include any parentheses at the end, so we are not calling the function but rather referring to the function itself.) This yields the same results as your code; you can use wait(1) instead of time.sleep(1). Also, you can import the function directly instead of importing the whole module, ie. from time import sleep Then you can just use sleep(1) in your code without having to refer to the time module. If you still wanted to use the name wait, you can give it another name when importing the function, ie. from time import sleep as wait. Answer from AtomicShoelace on reddit.com
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-time-sleep
Python time.sleep(): How to Pause Execution in Python Scripts | DigitalOcean
January 27, 2026 - This function is part of Python’s standard time module and is widely used in scripts that require controlled delays. In this article, you will learn how the time.sleep() function works and how to use it correctly in different scenarios. It explains how to add delays measured in seconds, how time.sleep() affects program execution, and why it pauses only the current thread rather than the entire application.
🌐
GeeksforGeeks
geeksforgeeks.org › python › sleep-in-python
time.sleep() in Python - GeeksforGeeks
July 11, 2025 - Python time sleep() function suspends execution for the given number of seconds.
Discussions

How to use time.sleep() within a function correctly?
You are using the same name time for both the time module and the argument of your function. However, if you want to do this you don't need to define a new function yourself. Python supports reassigning functions to different variable names, so you could just do wait = time.sleep (note its important we didn't include any parentheses at the end, so we are not calling the function but rather referring to the function itself.) This yields the same results as your code; you can use wait(1) instead of time.sleep(1). Also, you can import the function directly instead of importing the whole module, ie. from time import sleep Then you can just use sleep(1) in your code without having to refer to the time module. If you still wanted to use the name wait, you can give it another name when importing the function, ie. from time import sleep as wait. More on reddit.com
🌐 r/learnpython
8
4
February 9, 2021
Python time.sleep() Explained (2026 Guide with Examples, Threads & Async)
Step-by-step guide to using Python time.sleep() for delays, loops, retries and threading. Includes millisecond timing and performance considerations More on accuweb.cloud
🌐 accuweb.cloud
1
December 1, 2023
python - How do I make a time delay? - Stack Overflow
We're building a database here ... great new question, even. Something along the lines of "How to make a time delay in Python while using tkinter" or similar. 2018-04-10T15:29:46.553Z+00:00 ... Use sleep() from the time module.... More on stackoverflow.com
🌐 stackoverflow.com
How accurate is python's time.sleep()? - Stack Overflow
The time.sleep method has been heavily refactored in the upcoming release of Python (3.11). Now similar accuracy can be expected on both Windows and Unix platform, and the highest accuracy is always used by default. More on stackoverflow.com
🌐 stackoverflow.com
🌐
Real Python
realpython.com › python-sleep
Python sleep(): How to Add Time Delays to Your Code – Real Python
August 1, 2023 - The time module has a function sleep() that you can use to suspend execution of the calling thread for however many seconds you specify. ... If you run this code in your console, then you should experience a delay before you can enter a new ...
🌐
Programiz
programiz.com › python-programming › time › sleep
Python sleep() (With Examples)
import time print("Printed immediately.") time.sleep(2.4) print("Printed after 2.4 seconds.") ... Printed immediately. Printed after 2.4 seconds. ... import time while True: # get current local time as structured data current_time = time.localtime() # format the time in 12-hour clock with AM/PM formatted_time = time.strftime("%I:%M:%S %p", current_time) print(formatted_time) time.sleep(1)
🌐
Tutorialspoint
tutorialspoint.com › python › time_sleep.htm
Python time sleep() Method
Once compiled and run, the program prints the numbers after sleeping for 2 seconds each − · Start program 0 Program halted for 2 seconds 1 Program halted for 2 seconds 2 Program halted for 2 seconds 3 Program halted for 2 seconds 4 Program ...
🌐
Mimo
mimo.org › glossary › python › time-sleep
Python time sleep: Pausing Code Execution in Python
Pause Python programs with time.sleep(). Learn to add delays for tasks, manage countdowns, limit API requests, and create smooth workflows.
🌐
Python
docs.python.org › 3 › library › time.html
time — Time access and conversions
Similar to process_time() but return time as nanoseconds. Added in version 3.7. ... Suspend execution of the calling thread for the given number of seconds. The argument may be a floating-point number to indicate a more precise sleep time.
Find elsewhere
🌐
Hostman
hostman.com › tutorials › python time.sleep() function: a comprehensive guide
Python time.sleep() Function: How to Use and Best Practices
December 11, 2024 - What is the sleep() Function in Python? Python's time.sleep() function can be used to freeze the current thread's execution for a specific period of time. The built-in time module in Python contains this function.
Price   $
Address   1999 Harrison St 1800 9079, 94612, Oakland
🌐
Reddit
reddit.com › r/learnpython › how to use time.sleep() within a function correctly?
r/learnpython on Reddit: How to use time.sleep() within a function correctly?
February 9, 2021 -

Long story short i am making a rpg games (text based) in python and need a little help. I am using the time library to give a delay between certain ASCII banners popping up in the console. However, i dont want to have to write out 'time.sleep()' or copy and paste it every time i want to use it. Therefore, i made a function which I would use to shorten the time it would take me to right out 'time.sleep()':

def wait(time):

time.sleep(time)

wait(1)

Whilst in theory i thought this would work (im new to python, i have much to learn yet), it gives me this error:

time.sleep(time)

AttributeError: 'int' object has no attribute 'sleep'

I was wondering if anyone could help/point me in the right direction on how to go about this problem. Thanks in advance!

🌐
Zero To Mastery
zerotomastery.io › blog › python-sleep
Beginner’s Guide to Python’s Sleep Command | Zero To Mastery
September 1, 2025 - Using tools like Python, GPTs, and more! ... It'll show you how to automate all of the boring or repetitive tasks in your life - and makes for some pretty standout portfolio projects as well! With all that out of the way, let's get into this 5-minute tutorial! At its heart, time.sleep() is Python’s way of pausing whatever it’s doing at the time.
🌐
DataCamp
datacamp.com › tutorial › python-time-sleep
Python time.sleep() Function | DataCamp
January 31, 2019 - The accuracy really depends on the underlying operating system's sleep accuracy and if you need to look up further - it will do you good to look at the platform documentation because the semantics of these functions vary among platforms. However, there is some good news: starting with Python version 3.5, the time.sleep(secs) now sleeps at least secs(argument passed) even if the sleep is interrupted by a signal (again, imagine the signal to be a salesperson as discussed above), except if the signal handler raises an exception.
🌐
Python Central
pythoncentral.io › pythons-time-sleep-pause-wait-sleep-stop-your-code
Python's time.sleep() - Pause, Stop, Wait or Sleep your Python Code | Python Central
December 30, 2021 - Python's time module has a handy function called sleep(). Essentially, as the name implies, it pauses your Python program. The time.sleep()command is the equivalent to the Bash shell's sleep command.
🌐
StrataScratch
stratascratch.com › blog › python-sleep-function
How to Use Python’s Sleep Function - StrataScratch
October 14, 2025 - What it does is stop your program from running for a certain amount of time. You could think of it as a short-term "wait" order. The program does nothing else while it sleeps; it just stays still. If you’d like to explore more advanced techniques for introducing execution delays, check out ...
🌐
Edureka
edureka.co › blog › python-time-sleep
Python time Sleep() | time.Sleep() Method in Python | Edureka
November 27, 2024 - If you want to stop execution for a smaller period of time there are limitations to this function depending on the operating system as this function uses operating systems sleep() function, in Linux the wait time can be smaller than that compared with windows. ... In the above article we covered the sleep() method in python which is basically used to add a delay in program execution, this package is in the time module in Python which basically uses sleep() function of the underlying operating system.
🌐
freeCodeCamp
freecodecamp.org › news › python-sleep-time-sleep-in-python
Python Sleep – time.sleep() in Python
March 17, 2022 - While running a Python program, there might be times when you'd like to delay the execution of the program for some seconds. The Python time module has a built-in function called time.sleep() with which you can delay the execution of a program. ...
🌐
Accuweb
accuweb.cloud › home › python time.sleep() explained (2026 guide with examples, threads & async)
Python time.sleep() Explained (2026 Guide with Examples, Threads & Async)
December 1, 2023 - Step-by-step guide to using Python time.sleep() for delays, loops, retries and threading. Includes millisecond timing and performance considerations
🌐
SW Hosting
swhosting.com › en › blog › python-sleep-function
Python sleep() function - SW Hosting's Blog
May 1, 2024 - The Python sleep() function is used as follows: # We import the time module import time time= 4 # 4 seconds time.sleep(time)