voidinit
10-31-2006, 01:59 AM
For years I've been sitting down to explore Python, cracking open the tutorial, looking at the outright silly sytax, thinking 'Eww', and going back to what I know.
At work last week I had to make a few minor changes to a Python program we bought at one point in time. While doing this I began to think about how
many widely used programs there are that are implemented in Python in some way. Xen, portage, RPM and anaconda are just a few of the apps written partially or otherwise in Python. With that in mind, and my love for reptiles (especially herps, I own two 7ft (2.1m) long Columbian Boas & 1 3 ft (1m) long Ball Python) I set out to learn Python this past weekend.
Once I got over some of the more rediculous aspects of Python's syntax, the usefullness and power of the language became instantly appearent. I'm quickly beginning to see myself doing a lot more with this language at work. I've even started replacing some of my more resource intensive monitoring and maintenence scripts with Python versions. There are several key features that have hooked me on Python. "Everthings an object" model is quite a comfortable fit for a programmer with a Java back ground. A simple and elegant thread model is something I can't have in Bash or PHP, and a working thread model isn't even available in Perl. (IMHO threaded perl is currently barely usable, contradict me at will, but our highly paid perl experts have implemented threaded perl in one small corner of our enterprise. It took a huge effort and it barely works.)
The modules are extensive and the standard DB-API implementation makes working with MySQL (MySQLdb), which I do a lot, a breeze. CGI support is a KISS simple no-brainer, though I haven't tried to do anything fancy like session persistence or multipart forms. What really got my mind racing imagining the usefullness of this language was pickle. Persist any object to any medium at any time, and read it back in....even into other programs! Woah! Oh, and once again...pickle is KISS simple and a breeze to do. Unlike say *cough* Java Serialization *cough*
There are some downsides. Syntactically Python can be a really funky. I suppose it's just a matter of style, but honestly, example 1 below shouldn't be possible. There is no switch! WTF?! I know polymorphism is supposed to make the switch obsolete, but it sure would be nice if I didn't have to go though subclassing and overloading if I didn't want to. And finally, the object orientation of Python can be a little klunky. Personally I don't like the idea of spontaneous class members, and a simple typo can lead to bugs that are difficult to detect. I also don't like not having scope modifires on class functions/members (private, protected, public). Finally some of the expressions, genorators or otherwise can be a little hard to follow, even if you are the author.
Overall, I give it a big thumbs up, and I have big plans for putting this gem of a language to practical use in our organization.
Example 1:
Whoever thought the following was a good idea should be racked. (Either kicked in the balls, or in the medieval sense)
text = """ This is a paragraph of text to demonstrate some python rediculousness.
I'm sure there's something even more rediculous in here, but this just might have to do."""
for char in [ char for line in text.split("\n") for word in line.split(" ") for char in word ]:
print char
This was just a rant, any comments or suggestions would be appreciated. I have only one real question. Which of the SNMP modules available for Python would you all consider the most complete and production ready (SNMP v3 required)
At work last week I had to make a few minor changes to a Python program we bought at one point in time. While doing this I began to think about how
many widely used programs there are that are implemented in Python in some way. Xen, portage, RPM and anaconda are just a few of the apps written partially or otherwise in Python. With that in mind, and my love for reptiles (especially herps, I own two 7ft (2.1m) long Columbian Boas & 1 3 ft (1m) long Ball Python) I set out to learn Python this past weekend.
Once I got over some of the more rediculous aspects of Python's syntax, the usefullness and power of the language became instantly appearent. I'm quickly beginning to see myself doing a lot more with this language at work. I've even started replacing some of my more resource intensive monitoring and maintenence scripts with Python versions. There are several key features that have hooked me on Python. "Everthings an object" model is quite a comfortable fit for a programmer with a Java back ground. A simple and elegant thread model is something I can't have in Bash or PHP, and a working thread model isn't even available in Perl. (IMHO threaded perl is currently barely usable, contradict me at will, but our highly paid perl experts have implemented threaded perl in one small corner of our enterprise. It took a huge effort and it barely works.)
The modules are extensive and the standard DB-API implementation makes working with MySQL (MySQLdb), which I do a lot, a breeze. CGI support is a KISS simple no-brainer, though I haven't tried to do anything fancy like session persistence or multipart forms. What really got my mind racing imagining the usefullness of this language was pickle. Persist any object to any medium at any time, and read it back in....even into other programs! Woah! Oh, and once again...pickle is KISS simple and a breeze to do. Unlike say *cough* Java Serialization *cough*
There are some downsides. Syntactically Python can be a really funky. I suppose it's just a matter of style, but honestly, example 1 below shouldn't be possible. There is no switch! WTF?! I know polymorphism is supposed to make the switch obsolete, but it sure would be nice if I didn't have to go though subclassing and overloading if I didn't want to. And finally, the object orientation of Python can be a little klunky. Personally I don't like the idea of spontaneous class members, and a simple typo can lead to bugs that are difficult to detect. I also don't like not having scope modifires on class functions/members (private, protected, public). Finally some of the expressions, genorators or otherwise can be a little hard to follow, even if you are the author.
Overall, I give it a big thumbs up, and I have big plans for putting this gem of a language to practical use in our organization.
Example 1:
Whoever thought the following was a good idea should be racked. (Either kicked in the balls, or in the medieval sense)
text = """ This is a paragraph of text to demonstrate some python rediculousness.
I'm sure there's something even more rediculous in here, but this just might have to do."""
for char in [ char for line in text.split("\n") for word in line.split(" ") for char in word ]:
print char
This was just a rant, any comments or suggestions would be appreciated. I have only one real question. Which of the SNMP modules available for Python would you all consider the most complete and production ready (SNMP v3 required)