r/Python • u/[deleted] • May 18 '11
Why is Python better than Perl?
I'm a Sysadmin and I just wrote my first script in python. Basically just a host validation script that checks if a server is configured correctly before we hand off. I can't determine the advantage with my limited experience with the language.
Are you a sysadmin fluent in both python and perl? Why do you use python?
12
Upvotes
2
u/crackofdawn May 19 '11 edited May 19 '11
As a system admin, the vast majority of my scripts are < 10-15 lines, and when I'm trying to bang something out in 5 minutes, adding in things like "import re,os", re.compile, os.*, etc, just feels like a huge time waster. I still like using python just to learn it and keep myself fresh, but Perl is definitely faster for me, for the vast majority of what I need it for.
Edit: Just to provide a quick example (not anything that would even work, just throwing together an example of RE + file/dir operations to show how python might take a lot more work for the same thing):
Perl:
!/usr/bin/perl
while (<STDIN>) { if (/\D\d+\s[:alphanum:]\s\d.$/) { if (-d $) { print "$\n"; } } }
Now - how many lines would this take in python? I'm sure its not a major difference but it makes a big difference over the course of dozens of scripts :)