Mastering Python's Built-in time Module (Summary)
Congratulations! You’ve learned the fundamental concepts surrounding date and time. It’s time for you to apply your newfound knowledge in your real world applications.
In this course, you learned how to:
- Use a floating point number, representing seconds elapsed since the epoch, to deal with time
- Manage time using tuples and
struct_time
objects - Convert between seconds, tuples, and timestamp strings
- Suspend the execution of a Python thread
- Measure performance using
perf_counter()
If you want to continue learning more about using dates and times in Python, take a look at the following modules:
datetime
: A more robust date and time module in Python’s standard librarytimeit
: A module for measuring the performance of code snippetsastropy
: Higher precision datetimes used in astronomy
You might also want to check out How to Get and Use the Current Time in Python.
Congratulations, you made it to the end of the course! What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment in the discussion section and let us know.
00:00
Over the course of this series, you’ve learned a whole lot about the Python time
module. You’ve learned about epochs, time zones, and daylight savings time: the building blocks of how Python represents time.
00:11
You’ve learned several different objects that you can use in your code to represent time, like floats, tuples, the struct_time
, and even strings.
00:19
You’ve learned how those objects form a kind of bi-directional continuum with ease of operability for machines on one side, and then ease of intelligibility for humans on the other. Finally, you’ve learned how to convert between different time representations, and you’ve learned a couple of useful functions that the time module offers you, like the sleep
function that you can use to suspend thread execution, and the perf_counter
function, which gives you a really precise measuring tool that you can use to either measure your code performance or, really, any other time where you need a precise time span. If you’re interested in Python time and dates more broadly, then I would say that you should go next to the Python datetime
module, and there are Real Python tutorials on that module as well.
01:03
It’s a really fantastic module, especially for date manipulation, so check that out. In the meantime, thank you very much for watching this Real Python video tutorial series on the time
module. I had a really good time teaching it, and I hope you had a good time learning from it as well.
Become a Member to join the conversation.
Ghani on Oct. 28, 2020
Excellent course; thank you very much!