Book Image

Mastering Python Scripting for System Administrators

By : Ganesh Sanjiv Naik
Book Image

Mastering Python Scripting for System Administrators

By: Ganesh Sanjiv Naik

Overview of this book

Python has evolved over time and extended its features in relation to every possible IT operation. Python is simple to learn, yet has powerful libraries that can be used to build powerful Python scripts for solving real-world problems and automating administrators' routine activities. The objective of this book is to walk through a series of projects that will teach readers Python scripting with each project. This book will initially cover Python installation and quickly revise basic to advanced programming fundamentals. The book will then focus on the development process as a whole, from setup to planning to building different tools. It will include IT administrators' routine activities (text processing, regular expressions, file archiving, and encryption), network administration (socket programming, email handling, the remote controlling of devices using telnet/ssh, and protocols such as SNMP/DHCP), building graphical user interface, working with websites (Apache log file processing, SOAP and REST APIs communication, and web scraping), and database administration (MySQL and similar database data administration, data analytics, and reporting). By the end of this book, you will be able to use the latest features of Python and be able to build powerful tools that will solve challenging, real-world tasks
Table of Contents (21 chapters)

Chapter 5, Handling Files, Directories, and Data

  1. By using the pathlib library.

  2. Following is the answer:
print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False)
  1. If called without an argument, return the names in the current scope. Otherwise, return an alphabetized list of names comprising (some of) the attributes of the given object, and the attributes reachable from it.
  2. A DataFrame is a two-dimensional size, mutable, and potentially heterogeneous tabular data structure with labeled axes.
    Series is the data structure for a single column of a DataFrame, not only conceptually, but literally; that is, the data in a DataFrame is actually stored in memory as a collection of series.
  3. List comprehensions provide a concise way to create new lists.
  4. Yes:
Set comprehension {s**2 for s in range(10)}
Dict comprehension {n: n**2 for n in range(5)}
  1. Following...