AutomateTheBoringStuff.Ch15 package¶
Subpackages¶
Submodules¶
AutomateTheBoringStuff.Ch15.P1_timeModule module¶
Time module
This program uses time to reference the Unix epoch as a timestamp.
AutomateTheBoringStuff.Ch15.P2_calcProd module¶
Calculate product
Uses time to profile a function that calculates the product of the first 100,000 numbers.
Note
AutomateTheBoringStuff.Ch15.P3_stopwatch module¶
Stopwatch
A simple stopwatch program with lap times.
AutomateTheBoringStuff.Ch15.P4_datetimeModule module¶
datetime module
This program uses datetime to manipulate dates and times.
AutomateTheBoringStuff.Ch15.P5_threadDemo module¶
Thread demo
This program uses threading to demonstrate multithreading.
-
AutomateTheBoringStuff.Ch15.P5_threadDemo.takeANap() → None[source]¶ Take a nap
Simple 5 second timer using
time.sleep()followed by a ‘Wake up!’ print statement.Returns: None. Waits 5 seconds, then prints an exclamation.
AutomateTheBoringStuff.Ch15.P6_multithreading module¶
Multithreading
This program demonstrates threading.Thread on print().
AutomateTheBoringStuff.Ch15.P7_multidownloadXkcd module¶
Multidownload XKCD
Downloads 1400 XKCD comics much faster by using threading.
Note
Default output directory is ./xkcd.
-
AutomateTheBoringStuff.Ch15.P7_multidownloadXkcd.downloadXkcd(startComic: int, endComic: int) → None[source]¶ Download XKCD
Uses
requestsandbs4to download all comics in a given range.Parameters: - startComic – Comic ID number to start from.
- endComic – Comic ID number to end at.
Returns: None. Prints status updates and downloads comics to download directory.
AutomateTheBoringStuff.Ch15.P8_popenFunction module¶
Popen function
This program uses subprocess.Popen to launch programs.
AutomateTheBoringStuff.Ch15.P9_countdown module¶
Countdown
A simple countdown script that plays an alarm after a given number of seconds.
Note
- Sound file can be downloaded from http://nostarch.com/automatestuff/