The diary of a dedicated Ubuntu user that lucked into his dream job working on the Ubuntu team.

Saturday, February 20, 2010

Learning Python, what I wish they told me

On Thursday I will be running a couple of little sessions to kick off Opportunistic Developer Week. One of these will be for folks who know a little or a lot of programming today, but haven't tried or gotten into Python:

The reason I was excited about doing this session, is I remember when I was struggling to figure out how to write programs for Ubuntu. It was sad and frustrating that it was so hard to figure out what languages, libraries, and tools to use, because I could already write programs for Windows (I was working at Microsoft at the time, after all), and I could write web sites. I'll never claim to be anything but an opportunistic programmer, but when I fell in love with Ubuntu as a platform, I could make things happen on other platforms, but just couldn't get going with Ubuntu without lots of struggling. In fact, I essentially quit my job so that I could dedicate myself to solving this problem for Ubuntu. At the time, of course, I never dreamed that I'd actually get to work for Canonical and get paid to work on FOSS software. I thought I'd be lucky to pick up some opportunities to do some training and writing about it, targeted at folks migrating from Windows to Ubuntu.

Before I even quit my job, I tried my hand at contributing to solving this "how do I get started" problem by writing some "chapters". They are here, but there are some wrongnesses in them. Feel free to grab them, read them, modify them, share them, etc... However, beware, there are some wrong things in them that I need to fix. For example, the code samples us one space for indents instead of 4, I didn't understand how underscores worked, or the difference between "==" and "is". I know there are more, but hey, it was a start.

So I went through a couple of the chapters to put together and outline for the session. My goal for the session will basically be to help build a bridge between languages people know now to Python.

Here are my notes so far. I will go through and make code samples and such to get ready and make the session very productive.

Language Concepts1. Indentation levels- controls scoping instead of {}, "end", etc...- standard is to use 4 spaces for each indentation level- you will get used to it, and probably format you code this way anyway- at first, many errors will be caused by this

2. Strong Dynamic Typing- Object and sibclasses, int, float, etc...- A variable can change type- don't declare variables with types- can convert a *variable* to another type, not casting and assigning

3. OO syntax- instantiating object- no private variables, really? - convention: start with _ for members that should be private and inheritable - start with __ for members that should be private and not heritable (munging)

Tanks for writing this. I wrote blog posts about "It was sad and frustrating that it was so hard to figure out what languages, libraries, and tools to use" over the last few days. Ubuntu has missed many big opportunities to build a large developer community over the years. It's quite sad.

In fact, if you go to the Ubuntu Developer page on the Ubuntu Wiki, you don't get anything but how to get involved in packaging and some information about governance. The equivalent pages for Windows and OS X include extensive advice about how to set up your environment, what languages to use, what IDEs to use, and where the videos and tutorials are.

Quite sad, really.

Here's the full thing:http://blog.ibeentoubuntu.com/2010/02/making-myself-clear-about-ubuntu.html

@Martijn - thanks for the pointer. Just for clarity though, that was a rhetorical question to cover with folks when I try to induct them from their current languages into Python. I'll for sure check out your link though.

I agree with Martijn, this textfield is so much of the suck. You can't move the cursor with the keyboard, and can't use home/end keys. The only way to move the cursor is by using the mouse!Otherwise good article. Been trying to pick up a bit of Python myself to do some stuff with Bazaar.

—that sentence does not make sense; only values/objects can be cast; values/objects can be cast in any language... it's just type conversion.

what you meant to say was probably that you can you can assign a value of a different type to a variable than what it was previously holding, but then the sentence "A variable can change type" already says it.