return to I Love My Journal
A Little Closer to Center...
Musings about Life, Linux, and Latter-day Saints.
Pages
About Me
Links


Tags
PERSONAL 520
SPIRITUAL 416
LDS 312
BOOK OF MORMON 237
SCRIPTURES 154
STUDIO-JOURNEY 129
RELIGION 112
LINUX 79
COMPUTERS 65
LIFE 60
GENERAL CONFERENCE 46
GENTOO 39
MISCELLANEOUS 37
MUSIC 37
PROGRAMMING 33
CARS 29
MICROSOFT 23
FAMILY 23
AUDIO 21
I LOVE MY JOURNAL 18
FUN 15
CHILDREN 12
CURRENT EVENTS 10
NATURE'S WAY 10
VIDEO 9
DRM 9
CONEXM 7
BABBLINGS 7
PROVO CITY CENTER TEMPLE 6
FRIENDS 6
HEROD THE FINK 5
GAMES 5
COMPUTER HARDWARE 5
DRUMS 4
HAND OF GOD 3
ADVERSITY 3
KDENLIVE 3
AUDIO HARDWARE 3
GENERAL INSANITY 3
STUDIO 3
THANKS4GIVING 2
CATS 2
MY JOURNAL 1
POETRY 1
FOREVERGREEN 1
EVERYDAY THOUGHTS 1
GOSPEL 1
PARENTING 1
YOUTH CONFERENCE 1
CHURCH NOTES 1
POLITICS 1


RSS Feed

RSS FeedSubscribe!
Thu - Jun 12, 2008 : 05:09 pm
okay
   rated 0 times
>>next>>
<<previous<<
My First Python Script
When I went in to my 6 month review about 4 month ago, I didnt know what I was in for.

I assumed things would go well because I had accomplished everything I set out to do and more, so I felt pretty good.

The interview went very well.  They complimented me on my work, the sales reports, the new web site, the money I was saving the company and all that.  Then he asked me what my goals would be for the next 6 months.

I didn't anticipate that, so, I asked him what he meant (read: stalled while I frantically thought of something I could do in six months).  He responded while I didn't listen at all - thinking.

About the time he was done saying whatever it was he was saying, the thought popped into my head, "Hey!  I'll try learning a new language!".

In the IRC room I lurk in daily, #UPHPU, the python language frequently was the subject of hot debate, so I blurted out,

"I'll learn Python."

And that was that.  Well...  It's now 4 months later, and the perfect opportunity presented itself for me to see what this Python is all about.

We received the old servers upon which the old website ran from the old company with whom we do no business anymore, thereby barring ourselves from further thievery.

I took a look at these servers and realized they are much beefier than the ones currently running the server.  So, my boss and I decided to wipe off the dross currently installed on them (read: Windows 2003 Server), and installed gentoo with a healthy LAPP stack on em'.

Well, the last thing I needed to do to get these suckers fully up and running was to install some sort of RAID monitoring system.  The old servers had the mdadm program taking care of the RAID.  These boxen have hardware RAID controllers on them, so using the mdadm monitor was out.

To make an already long story shorter, suffice it to say I found a program called cciss_vol_status which seemed to do the trick nicely.

I just needed to find a way to run it every day and email me the results.

Needless to say, this is where Python comes in.

My first impressions of Python, coming from PHP, of course, are the following:
  1. It seems very complicated.
  2. Why the need to import modules which PHP has natively?
  3. The learning curve for something new always sucks.  Thinking to myself, "I could have had this done 2 days ago, if I was doing it in PHP"
  4. Its syntax is radically different, and oddly attractive to me.
  5. From my noobie standpoint, it seems that Python has the potential to be much more powerful than PHP - after the learning curve.

Basically, I began writing the script yesterday, and worked on it for about 5 hours.  I finished the script after about 1.5 hours working on it today.  I'd have to say that 90% of the speed with which I finished it was due to the tutorials written online for the specific modules I needed.  The #python IRC channel provided a few clues as well.

Anyway...  I'd like to continue learning Python, but I'm not sure how suited it would be to web development.  I've got my nitche down really well within PHP, and it'd be a shame to stop that to learn something new - just for the sake of learning it.

The flip-side, however, is that with my knowledge of python (if I should choose to pursue it and learn it to the degree I know PHP), I'd be in a much better position to continue marketing myself.

We'll see.

Anyway...  That's today's story.

Life is good.
Comment by Ciaran McCreesh on Jun. 13, 2008 @ 03:32 am
Having to use (standard) libraries to get fairly basic things is generally a good sign, not a bad one. It means the language is flexible enough to let you write good, powerful libraries, rather than forcing you to rely upon whatever the language people happen to give you. In fact, one of the C++ design principles is that, where sensibly possible, things should be done by libraries (and the language should be extended to help people write libraries) rather than hardcoded into the language.

Of course, some languages take it too far... If you see a language that sticks integers in a library, be afraid -- if nothing else, because it probably means there's no constant folding or anything useful like that...
Comment by Josh Fenio on Jun. 13, 2008 @ 11:10 am
Congratulations!  A couple points:

  • The modules you import are native:  they're just not in the global namespace.  By importing modules, you have (almost) total control over what goes in the global namespace -- unlike PHP, where you'll have everything in the global namespace, and essentially end up only using perhaps 1 to 2 percent in a particular script.  This is a Good Thing (tm).  I promise.

  • What references are you using?  I'd suggest Learning Python, by O'Reilly.  It's a good beginner's book, I've used it to teach Python to several people fairly successfully. 

  • Sign up for the Python Tutors mailing list;  people are extremely helpful - particularly when it comes to advice on specific snippets or scripts.  They'll direct you toward a more "Pythonic" approach (read 'import this').



Congratulations again, and you can always hit me up in #uphpu if you have any questions regarding technical problems, style advice, etc.