OOP for System Administrator

Michael Torrie torriem at gmail.com
Sat Apr 4 15:04:27 EDT 2015


On 04/04/2015 09:56 AM, pankaj sharma wrote:
> I'm a Linux system administrator and my work requires me to write
> bash scripts (100-500 lines) for process monitoring, server health
> check and automate some manual processes. Now I've started to learn
> python as I want to write scripts in python rather than bash or any
> shell.
> 
> My questions is Do I need to learn Object oriented Python in order to
> be good at python scripting. I know basics of OOP but personally
> didn't like it much.

Let me guess.  Your exposure to OOP comes from Java or C#?  Python's use
of OOP is very natural and powerful.  But you don't have to use OO
design in your programs.  So no you don't need to learn oo Python, just
learn and use Python, period.  As needed you can benefit from the strong
OO capabilities of Python without having to use that paradigm for your
own programs.

>From a system programmer's point of view, other features of Python, like
generators are going to give you far more utility.  I recommend you take
a look at this presentation for how Python can fit in your work:

http://www.dabeaz.com/generators/

Note that while Python is a scripting language, it's not a shell
language. To interface with other processes, you'll have to use popen()
and connect to the standard pipes (in, out, err). It's not like bash
where any reference to a program in the path is executed and piped
automatically.  A long time  ago I wrote a little wrapper around popen()
to make it easier and faster to interact with unix commands.



More information about the Python-list mailing list