Python


C# & Python & Ruby20 Mar 2008 08:42 pm

Three semesters ago, when I began working as an adjunct, I was faced with a choice. I could start teaching my intro to programming course using the language and tools with which I was most comfortable (C#, VS.NET) or I could reuse the syllabus, quizzes, assignments and homeworks of the course as it had been taught in the prior semester (Python, Eclipse). I opted for the latter. Learning a new language seemed a more practical endeavor than learning to write a college course.

Since I’ve been working working with Python, I’ve started to let go of the “my language can beat up your language” attitude I’d held since leaving VB for C#. Of course C# can definitely beat up VB.NET, but I digress… As useful as type safety is, I no longer believe that it makes me a better person. I’ve grown very comfortable with writing code that is far less explicit than SomeClass sc = new SomeClass();.

I’ve been digging Python for some time now and have adopted IronPython as my favorite way to make my .NET apps extensible. Lately I’ve also been looking into Ruby. It’s clearly the product of a serious psychosis, but it’s proving to be a fascinating language. From strings to symbols to blocks, Ruby is just different enough to make learning a language exciting again.

Over the next few months as I continue my Python and Ruby exploration, I’ll share what I consider to be some of the more unique features that make these languages worth a look. I’ll end this post with one of my favorite features in Python - the else clause in while loops. Consider the following contrived example:

response = ""
while response != "valid":
     response = raw_input("Please enter a valid response: ")
else:
     print "Thank you for your valid response"

Teaching & Python & Eclipse & Mac27 Jan 2008 02:53 pm

This post is admittedly for a very small niche of readers. If you are a Windows user - with virtually no Mac experience - and happen to be teaching college students how to program Python with Eclipse then read on…

I recently began my third semester teaching Intro to Business Programming at Fairfield University. Python is the language of choice for this course. For an IDE, we use EasyEclipse, which packages useful plugins together by purpose (LAMP, Java, etc.). One of the LAMP plugins is PyDev, which adds a very nice set of tools for writing Python scripts in Eclipse. However, PyDev needs to be told where to find the Python interpreter. On Windows, this is no problem. Students almost always accept the Python installer’s default install path or change it to Program Files. But the Mac…

I’ve spent very little time on a Mac. I can find my way around to get some things done (basic office work). I’ve never installed or configured software on a Mac. I’m not sure I’ve ever even powered one up… I couldn’t even describe the basic setup of a Mac. Shameful, I know… I like Apple. My iPod Touch is amazing. This is probably the single most impressive gadget I own (and I own many). But I hate Apple’s software. I’ll save that for another post, but for now I’ll ask why the search box has to lose focus when I Alt-Tab out of and back to iTunes?

Anyway… So clearly I’m guessing when I try to help a student find his or her Python interpreter. Fortunately, Mac bundles a Python interpreter into its OS. So no install woes. For those in the niche I described above, here’s the interpreter path to lead your students to:

/System/Library/Frameworks/Python.framework/Versions/2.3/bin/python

As far as I could tell, there were about 3000 other ways to find paths containing Python. Not sure what those were all about.