{"id":262607,"date":"2026-07-13T19:09:38","date_gmt":"2026-07-13T16:09:38","guid":{"rendered":"https:\/\/1kitap1.com\/en\/hands-on-cisco-automation-with-python-rick-graziani-1\/"},"modified":"2026-07-13T19:09:38","modified_gmt":"2026-07-13T16:09:38","slug":"hands-on-cisco-automation-with-python-rick-graziani-1","status":"publish","type":"post","link":"https:\/\/1kitap1.com\/en\/hands-on-cisco-automation-with-python-rick-graziani-1\/","title":{"rendered":"Hands &#8211; On Cisco Automation With Python &#8211; Rick Graziani (1)"},"content":{"rendered":"<figure style=\"text-align:center;margin:0 auto 1.5em;\"><img decoding=\"async\" src=\"https:\/\/1kitap1.com\/en\/wp-content\/uploads\/2026\/07\/99cd613e1e703ec8.jpg\" alt=\" - Unknown book cover\" style=\"max-width:300px;width:100%;height:auto;box-shadow:0 4px 12px rgba(0,0,0,.25);border-radius:4px;\"\/><\/figure>\n<p>This makes isinstance() useful for conditional checks where you need to verify a value&#8217;s type before processing it. This is the syntax for the isinstance() function: isinstance(object, type) It returns True if the object is an instance of the specified type and False otherwise. Here is an example: isinstance(device_facts[&#8216;interface_list&#8217;], list) This function checks whether the value associated with the key &#8216;interface_list&#8217; is a list and returns True.<\/p>\n<p>Example 7-16 shows other types of values you can check for. Example 7-16 The isinstance() Function Returns True or False print(isinstance(device_facts[&#8216;interface_list&#8217;], list)) # Retur print(isinstance(device_facts[&#8216;interface_list&#8217;], dict)) # Retur print(isinstance(device_facts[&#8216;interface_list&#8217;], float)) # Retur print(isinstance(device_facts[&#8216;interface_list&#8217;], int)) # Retur print(isinstance(device_facts[&#8216;interface_list&#8217;], bool)) # Retur print(isinstance(device_facts[&#8216;interface_list&#8217;], str)) # Retur Example 7-17 demonstrates how isinstance() can be used to check whether the dictionary value device_facts[&#8216;interface_list&#8217;] matches a specific type. Example 7-17 ex7-17_isinstance_function.py import napalm from pprint import pprint driver = napalm.get_network_driver(&#8216;ios&#8217;) device = driver( hostname=&#8217;192.168.1.1&#8242;, username=&#8217;admin&#8217;, password=&#8217;cisco&#8217;, optional_args={&#8216;secret&#8217;:&#8217;spot&#8217;} ) device.open() device_facts = device.get_facts() if device_facts[&#8216;interface_list&#8217;] is None: print(&#8216;interface_list has no data (None)&#8217;) elif isinstance(device_facts[&#8216;interface_list&#8217;], list): print(&#8216;interface_list is a list&#8217;) elif isinstance(device_facts[&#8216;interface_list&#8217;], dict): print(&#8216;interface_list is a dictionary&#8217;) elif isinstance(device_facts[&#8216;interface_list&#8217;], float): print(&#8216;interface_list is a float&#8217;) elif isinstance(device_facts[&#8216;interface_list&#8217;], int): print(&#8216;interface_list is an integer&#8217;) elif isinstance(device_facts[&#8216;interface_list&#8217;], bool): print(&#8216;interface_list is a boolean&#8217;) elif isinstance(device_facts[&#8216;interface_list&#8217;], str): print(&#8216;interface_list is a string&#8217;) else: print(&#8216;Unknown data type&#8217;) device.close() Example 7-18 shows that the output of Example 7-17 would be the same, interface_list is a list.<\/p>\n<p>Example 7-18 Output from Example 7-17 MyPrompt % python3 ex7-17_isinstance_function.py interface_list is a list MyPrompt % The isinstance() function is more flexible than type() because it allows you to check against multiple types and works with subclass relationships, making it more robust for evaluating dictionary values. However, for a beginning Python user, multiple types and subclasses are usually not relevant, and isinstance() is preferred over type() because it makes code easier to read, avoids unnecessary complexity when checking for None, and works well with both built-in and user-defined objects, ensuring better compatibility as coding skills grow.<\/p>\n<p>Note In network automation, None often appears (without quotes) when a device does not provide certain data. This can happen if an interface is down, a configuration field is unset, or the API response omits a value. Checking for None ensures that missing or uninitialized data is handled properly, preventing errors in further processing. Looping Through Key\/Value Pairs with .items() and Processing Values with isinstance() In this section, we bring together everything we have discussed so far in this chapter.<\/p>\n<p>The dictionaries in our examples\u2014specifically those returned by the get_facts() method (and later the get_environment() method\u2014are likely to contain various data types. These dictionaries are often heterogeneous (that is, containing different data types) and form the main dictionary, as discussed in Chapter 6. Later in this chapter, we will examine how to iterate through other types of dictionaries as well. When using a for loop with the .items() method to iterate through a dictionary, you may want to process both the key and its associated value.<\/p>\n<p>If Step 1. Step 2.<\/p>\n<blockquote>\n<p>Hands-On Cisco Automation with Python: Streamline Network Tasks Using Netmiko, NAPALM, and Nornir for Beginners Rick Graziani Adrian Iliesiu, CCIE No. 43909 Cisco Press OceanofPDF.com Hands-On Cisco Automation with Python: Streamline Network Tasks Using Netmiko, NAPALM, and Nornir for Beginners Rick Graziani and Adrian Iliesiu Copyright \u00a9 2026 Cisco Systems, Inc.<\/p>\n<p>Published by: Cisco Press Hoboken, New Jersey All rights reserved. This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permissions, request forms, and the appropriate contacts within the Pearson Education Global Rights &#038; Permissions Department, please visit https:\/\/www.pearson.com\/global-permission- granting.html.<\/p>\n<p>No patent liability is assumed with respect to the use of the information contained herein. Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions. Nor is any liability assumed for damages resulting from the use of the information contained herein.<\/p>\n<p>Please contact us with concerns about any potential bias at www.pearson.com\/en-us\/report-bias.html. $PrintCode Library of Congress Control Number: 2026932840 ISBN-13: 978-0-13546-319-2 ISBN-10: 0-1-35-46319-X Warning and Disclaimer This book is designed to provide information about using Python with Netmiko, NAPALM and Nornir to configure and manage Cisco devices. Every effort has been made to make this book as complete and as accurate as possible, but no warranty or fitness is implied.<\/p>\n<p>The information is provided on an &#8220;as is&#8221; basis. The authors, Cisco Press, and Cisco Systems, Inc. shall have neither liability nor responsibility to any person or entity with respect to any loss or damages arising from the information contained in this book or from the use of the discs or programs that may accompany it. The opinions expressed in this book belong to the author and are not necessarily those of Cisco Systems, Inc.<\/p>\n<p>Trademark Acknowledgments All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Cisco Press or Cisco Systems, Inc., cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark. Feedback Information At Cisco Press, our goal is to create in-depth technical books of the highest quality and value.<\/p>\n<p>Each book is crafted with care and precision, undergoing rigorous development that involves the unique expertise of members from the professional technical community. Readers&#8217; feedback is a natural continuation of this process.<\/p>\n<\/blockquote>\n<p><em>This is a short excerpt from the opening of &ldquo;&rdquo; by Unknown, quoted for review and introduction purposes. All rights belong to the copyright holders.<\/em><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_85 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/1kitap1.com\/en\/hands-on-cisco-automation-with-python-rick-graziani-1\/#Book_Information\" >Book Information<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/1kitap1.com\/en\/hands-on-cisco-automation-with-python-rick-graziani-1\/#Reading_Word_Statistics\" >Reading &amp; Word Statistics<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/1kitap1.com\/en\/hands-on-cisco-automation-with-python-rick-graziani-1\/#Most_Frequent_Words\" >Most Frequent Words<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/1kitap1.com\/en\/hands-on-cisco-automation-with-python-rick-graziani-1\/#PDF_Download\" >PDF Download<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Book_Information\"><\/span>Book Information<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li><strong>Unique ID:<\/strong> 99cd613e1e703ec8<\/li>\n<li><strong>File Extension:<\/strong> .pdf<\/li>\n<li><strong>File Size:<\/strong> 12,694,234 bytes (12.106 MB)<\/li>\n<li><strong>Title:<\/strong> &#8211;<\/li>\n<li><strong>Author:<\/strong> Unknown<\/li>\n<li><strong>ISBN:<\/strong> 9780135463192, 013546319X<\/li>\n<li><strong>Pages:<\/strong> 545<\/li>\n<li><strong>Language:<\/strong> English (en)<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Reading_Word_Statistics\"><\/span>Reading &amp; Word Statistics<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li><strong>Estimated Reading Time:<\/strong> 459.17 minutes<\/li>\n<li><strong>Total Words:<\/strong> 91,834<\/li>\n<li><strong>Total Characters:<\/strong> 659,697<\/li>\n<li><strong>Average Words per Page:<\/strong> 168.5<\/li>\n<li><strong>Average Characters per Page:<\/strong> 1210.45<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Most_Frequent_Words\"><\/span>Most Frequent Words<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>device (1102), example (810), nornir (775), napalm (600), data (599), netmiko (582), configuration (559), using (527), inventory (523), command (518), interface (510), print (510), dictionary (498), output (489), devices (475), key (464), python (459), network (439), value (434), gigabitethernet (412), config (403), yaml (401), list (392), cisco (384), connection (354), get (351), send (349), host (343), automation (334), use (319), ipv (317), method (313), commands (311), address (300), task (296), ios (279), facts (276), information (268), program (260), file (252), used (246), dictionaries (245), ssh (226), chapter (223), values (213), show (204), structured (203), hostname (194), type (189), code (187), hosts (186), result (183), table (177), cli (176), groups (170), object (169), step (165), changes (162), access (161), password (160), loop (159), run (159), router-r (158), import (155), multiple (153), one (150), keys (149), router (147), shows (145), tasks (144), plugin (140), username (137), variable (136), files (136), function (135), methods (132), mac (132), defaults (130), results (129), interfaces (129), version (127), directly (127), like (123), way (123), brief (123), structure (121), uses (121), book (120), different (120), mode (120), level (119), running (119), across (115), provides (113), name (112), yes (112), pprint (108), first (106), section (105), ansible (103).<\/p>\n<h2><span class=\"ez-toc-section\" id=\"PDF_Download\"><\/span>PDF Download<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align:center;\"><a href=\"https:\/\/1kitap1.com\/en\/wp-content\/uploads\/2026\/07\/hands-on-cisco-automation-with-python-rick-graziani-1.pdf\" download rel=\"nofollow\" style=\"display:inline-block;background:#2271b1;color:#ffffff;padding:14px 36px;border-radius:6px;text-decoration:none;font-weight:bold;font-size:1.05em;\">&#11015;&#65039; PDF Download<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This makes isinstance() useful for conditional checks where you need to verify a value&#8217;s type before processing it. This is the syntax for the isinstance() function: isinstance(object, type) It returns True if the object is an instance of the specified type and False otherwise. Here is an example: isinstance(device_facts[&#8216;interface_list&#8217;], list) This function checks whether the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":262605,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-262607","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-english"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/posts\/262607","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/comments?post=262607"}],"version-history":[{"count":0,"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/posts\/262607\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/media\/262605"}],"wp:attachment":[{"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/media?parent=262607"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/categories?post=262607"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/tags?post=262607"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}