DevNet Associate DEVASC 200-901 Official Certification Guide by Adrian Iliesiu (z-lib.org)

(andrew) #1

Chapter 5


Working with Data in Python


This chapter covers the following topics:


File Input and Output: This section shows how to work with test
files in Python.
Parsing Data: This section discusses how to parse data into native
Python objects.
Error Handling in Python: This section discusses how to use try-
except-else-finally to work through errors in Python input.
Test-Driven Development: This section discusses using software
testing to validate function.
Unit Testing: This section discusses how to use the internal Python
module unittest to automate Python code testing.
There are numerous ways to ingest data into a Python
program. You can get input from the user, pull data
from a website or an API, or read data from a file. The
trick is being able to convert data from a data source
into native Python structures and objects so that you
can use it to automate your infrastructure. This
chapter discusses a number of ways to use built-in and
third-party modules to transform different types of
data into Python dictionaries, lists, and other data
collection objects. The rest of the book provides more
detail on how to use these techniques to interact with
Cisco infrastructure; this chapter provides a
foundation for understanding how these data formats
differ and how best to interact with them.

“DO I KNOW THIS ALREADY?” QUIZ


The “Do I Know This Already?” quiz allows you to assess
whether you should read this entire chapter thoroughly
or jump to the “Exam Preparation Tasks” section. If you

Free download pdf