- Python Automation Cookbook
- Jaime Buelta
- 277字
- 2021-06-30 14:52:37
To get the most out of this book
- Before reading this book, readers need to know the basics of the Python language. We do not assume that the reader is an expert in the language.
- The reader needs to know how to input commands in the command line (Terminal, Bash, or equivalent).
- To understand the code in this book, you need a text editor, which will enable you to read and edit the code. You can use an IDE that supports the Python language, such as PyCharm and PyDev—which you choose is up to you. Check out this link for ideas about IDEs: https://realpython.com/python-ides-code-editors-guide/.
Download the example code files
You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files emailed directly to you.
You can download the code files by following these steps:
- Log in or register at http://www.packtpub.com.
- Select the SUPPORT tab.
- Click on Code Downloads & Errata.
- Enter the name of the book in the Search box and follow the on-screen instructions.
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
- WinRAR / 7-Zip for Windows
- Zipeg / iZip / UnRarX for Mac
- 7-Zip / PeaZip for Linux
The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Python-Automation-Cookbook-Second-Edition. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
Download the color images
We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://static.packt-cdn.com/downloads/9781800207080_ColorImages.pdf.
Conventions used
There are a number of text conventions used throughout this book.
CodeInText
: Indicates code words in text, object names, module names, folder names, filenames, file extensions, pathnames, dummy URLs and user input. Here is an example: "For this recipe, we need to import the requests
module."
A block of code is set as follows:
# IMPORTS
from sale_log import SaleLog
def get_logs_from_file(shop, log_filename):
def main(log_dir, output_filename):
...
if __name__ == '__main__':
# PARSE COMMAND LINE ARGUMENTS AND CALL main()
Note that code may be edited for concision and clarity. Refer to the full code when necessary, which is available at GitHub.
Any command-line input or output is written as follows (notice the $
symbol):
$ python execute_script.py parameters
Any input in the Python interpreter is written as follows (notice the >>>
symbol):
>>>
import delorean
>>> timestamp = delorean.utcnow().datetime.isoformat()
To enter inside the Python interpreter, call the python3
command with no parameters:
$ python3
Python 3.8.2 (default, Mar 11 2020, 00:28:52)
[Clang 11.0.0 (clang-1100.0.33.17)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
Verify that the Python interpreter is Python 3.8 or higher. It may be necessary to call python
or python3.8
, depending on your operating system and installation options. See Chapter 1, Let's Begin Our Automation Journey, specifically the Activating a virtual environment recipe—for further details about the use of different Python interpreters.
Bold: Indicates a new term, an important word, or words that you see on the screen, for example, in menus or dialog boxes. For example: "Select System info from the Administration panel."
Warnings or important notes appear like this.
Tips and tricks appear like this.