Archives for March 2011


Teaching conclusions

My last course to teach Python to beginners ended Monday last week and wow, am I behind in writing up the post-mortem :)

This time I taught the basics of programming with Python to a group of 6 adults, mostly PhD students either in political sciences or mechanical engineering. Nearly all of them had used some statistical/domain-specific language before, such as R or Matlab, which had a greater impact on the course than I anticipated. I taught in the students' University and thus was able to donate all the proceeds to Python Ireland, woohoo! To an awesome PyCon Ireland conference this October!

Progress isn't linear

The first and most important lesson, for me, was that progress isn't a linear thing and I really let the first session influence the pace too much. On the first day, we went through the material in a blink and I found myself short on exercises and concerned about the amount of new content that would be required for the rest of the course.

However, this day 1 effect happened because people were already familiar with the basics of programming, and they had no problem mapping what they knew to Python. I didn't realise this though, and stepped on the gas from that point on, failing to adjust properly until several weeks later. It was brought to my attention later on that actually students could have used more time and depth to understand several new concepts (that's where it helps to have a friend as part of your students, they'll mention it even if in passing!)

Which reminds me: note to self, completely redo the way you introduce for loops.

Initially, I was also a bit disappointed because I enjoy guiding students through the ah-ha! moments of figuring out programming and it felt like people already knew everything. I was wrong here as well, there may not have been any in the first session but there were plenty of satisfying ah-ha moments as we went on with the course.

Preparing

As usual, I started crashing toward the end of the course ; preparing and refining material and exercises always takes a ton of personal time and when the course ended I was much looking forward to having time again to work on my own projects (...till the next course, as usual! I never learn ;))

Preparations are really the most time- and mind-consuming aspect of teaching. Even for the existing material, there's always a bit of work to try and adapt the exercises to topics that might interest current students or make lessons flow better. With the pace we were going at, I didn't have everything ready beforehand either. On the minus side, this costs time and means the lessons can be less polished. On the plus side, it usually means the lessons are better suited to the level and interests of the class.

Student feedback

This is probably another reason why it took a bit of time to sit down and write this all up. Overall, on the scale of happiness and knowledge the students appear satisfied with the course. Some comments on how to improve the course somewhat confused me. I think once again some felt I was guiding too much. However this time I'm really happy with how we learnt to use and navigate the Python documentation and I think that's the best thing I can teach for students to become independent. At that beginner level, I'm afraid I'm not sure what more to do unless I'm offered specific suggestions. There was another piece of feedback about still not being sure where to start if wanting to create a new program. Something I'd like to experiment with in the future is to start by giving a big project at the beginning of a course, and then along the weeks with various exercises we start solving it bit by bit, and hopefully that would give students a fairer idea on how to break down problems into manageable tasks. I need to think about it.

Some of the feedback wondered about the point of some of the exercises, which is very valid criticism. When I create a new lesson and associated batch of exercises, the ratio of suck tends to be high. It's quite difficult to find small self-contained exercises, that touch only on the necessary specific concepts without going all over the place! I need to hunt for more.


Overall I'm happy with how it went and will of course teach again in the future. I'm disappointed with the way I presented the material at times though. I think I need to do more public speaking and general talks, to stop letting myself become intimidated when I speak for a while and no one's looking my way or interested (or awake!)... as opposed to the pleasant interactions of helping students debug their programs. Maybe a lightning talk on teaching programming? ;)

Update: Oh, and I forgot to mention I received homework this time! This is so cool. It came from students who had a project on the side they wanted to solve with Python. Hope I helped :)

Leave a comment | 4 so far

Getting started with virtualenv

After switching to pip a while back ("pip uninstall", oh yeah!) I thought it was time to tame virtualenv, as pip and virtualenv tend to be introduced as the ideal way to work with Python nowadays. I started poking at it properly today, here's where I am so far.

$ pip -E mycoolenv install stuff 

...That, does not really seem to work for me. Global dependencies still get picked up. I'll play with it more.

In the meantime, I've been doing the following. I'm sure it'll get more elegant and refined as I get used to the tool -- I'm writing this down now so I don't have to figure it all out again next week!

$ virtualenv --no-site-packages mycoolenv

This creates a folder "mycoolenv" with 3 subdirectories, bin, include and lib. After cd-ing into the new folder:

$ source bin/activate

Theoretically this changes your $PATH etc to point to the virtualenv bin/ directory. I don't think I've fully grokked it yet. I thought this meant if I run "python" it would now run it from mycoolenv/bin/python but that doesn't seem to be the case. So I'm linking to it manually in the meantime. [Update: Seems to work for me now, I was probably doing it wrong! 'which python' does link to the binary in the virtual env.] Then:

$ bin/pip install <all my dependencies>

For now this is enough for what I want to do, comparing different Django versions output (e.g. ../mycoolenv/bin/python manage.py runserver). Looking forward to learning more about it and using its full power!

Leave a comment

Testing django admin customisations

In preparation for an upgrade, I've been writing unit tests for a Django app with the help of a fantastic book -- Django 1.1 Testing and Debugging by Karen M. Tracey, there'll be a review coming up when I finish it.

I had some issues with the code to test admin customisations (Chapter 4), I want to document the changes I made for future reference.

Error 403

Despite using client.login() in the setUp() method, response returned with a status_code of 403 (Forbidden) when creating a new item.

class AdminCustomisationTest(TestCase):
    
    def setUp(self):
        username = 'test_user'
        pwd = 'secret'

        self.u = User.objects.create_user(username, '', pwd)
        self.u.is_staff = True
        self.u.is_superuser = True
        self.u.save()

        self.assertTrue(self.client.login(username=username, password=pwd),
            "Logging in user %s, pwd %s failed." % (username, pwd))

        Survey.objects.all().delete()

    def tearDown(self):
        self.client.logout()
        self.u.delete()

    def test_add_survey_ok(self):
        self.assertEquals(Survey.objects.count(), 0)

        post_data = { 'title': u'Test OK',
                      'open_date': datetime.now(),
                    }

        response = self.client.post(reverse('admin:survey_survey_add'), post_data)

        self.assertRedirects(response, reverse('admin:survey_survey_changelist'))
        self.assertEquals(Survey.objects.count(), 1)

At first I blamed some customisations I did to the authentication backends to allow OpenID, however printing the response.content revealed otherwise:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><body><h1>403 Forbidden</h1><p>Cross Site Request Forgery detected. Request aborted.</p></body></html>

The Django CSRF protection system prevented the tests from passing. Note that this app runs on Django 1.1, Django 1.2 overhauled the CSRF system and would likely work without problems.

I'm sure there are more elegant ways to solve this. Here's a method that works:

    def get_csrf_token(self, response):
        csrf = "name='csrfmiddlewaretoken' value='"
        start = response.content.find(csrf) + len(csrf)
        end = response.content.find("'", start)

        return response.content[start:end]

    def test_add_survey_ok(self):
        self.assertEquals(Survey.objects.count(), 0)

        response = self.client.get(reverse('admin:survey_survey_add'))
        csrf = self.get_csrf_token(response)
        post_data = { 'title': u'Test OK',
                      'open_date': datetime.now(),
                      'csrfmiddlewaretoken': csrf,
                    }

        response = self.client.post(reverse('admin:survey_survey_add'), post_data)

        self.assertRedirects(response, reverse('admin:survey_survey_changelist'))
        self.assertEquals(Survey.objects.count(), 1)

(Note/Update: If I had waited until the next chapter, I would have found out how to integrate Twill with Django apps and none of this would have been necessary -- haha!)

This field is required (datetime)

After this, although the response.status_code was finally 200, the article still wasn't created. Peering through response.content showed that the datetime field was considered to be missing. This is what the postdata should look like instead for a datetime field:

        post_data = { 'title': u'Test OK',
                      'open_date_0': '2011-03-17',
                      'open_date_1': '9:50:00',
                      'csrfmiddlewaretoken': csrf,
                    }

Test passes!

Leave a comment

Excellent talk on outreach and growing your community Moar contributors moar

I've been having a great time perusing through the PyCon 2011 video archives and watching some of the talks. Turns out most of them are 30 minutes long, which is a lovely amount of time -- a bus journey, a late afternoon break, etc, and exactly the length of my attention span :-)

Here's a link to an excellent talk on growing your community of contributors, with actual tried-in-real-life examples and how and why they work and what you can do to improve your own project. In case Python's not your thing, it's actually not very Python-specific ; there are many examples from different communities (Debian, OpenHatch, ...)

PyCon 2011: Get new contributors (and diversity) through outreach by Asheesh Laroia.

"Diversity" sort of remains in the background of the talk, rarely directly mentioned, and I think it makes sense. If you spend the time nurturing new contributors and making sure to create an environment where it's ok to learn, you're more likely to get people from different walks of life showing up.

Leave a comment

Dexy Documentation Workshop in Tog

I'm facilitating-slash-attending a day-long workshop on Dexy in Tog next Saturday, March 26th. Dexy is an open-source tool for code documentation. The workshop will be presented and led by Dexy creator Ana Nelson and promises to be both interesting and a ton of fun :-) Ana plans to make it very hands-on, an open-source project will be selected beforehand so that the documentation we create is useful and meaningful. I'm really looking forward to it!

You can learn more about this...

...on Tog's related blog post

...and on the event sign-up page.

The event is free and everybody is welcome! Please sign up beforehand though, as places are limited.

And on a related note, if you're around Dublin and an open-source contributor, and would like to prepare that kind of event for your project, please chat with me. I would love to have more of these workshops in Tog!

Leave a comment | 2 so far

Book reviews: The Stolen Throne, & The Calling, by David Gaider (Dragon Age)

Late last year I took a shine to the Dragon Age game, and since I enjoyed the story and the world so much I though I would -*gasp*- read the franchise books and learn more about it, starting with the Stolen Throne. Now both books are your average fantasy book, heavily stereotypical on the story, characters and their antics, and here even most of the plot... Still it ended up being quite an enjoyable backstory, that genuinely helps understand some of the characters in the game better; we follow Maric and Loghain as they meet and attempt to drive the Orlesians out of Ferelden.

There are a few things that didn't seem to make sense to me, however the author is the lead writer of the game so I must assume I didn't pay enough attention while playing (e.g. the Dalish elves speak a different language? If you play one in the game they keep saying how much of their past is lost, including the language.) In the end if you're able to overlook the lack of originality, you'll have a good read, particularly if you enjoyed the game's world.

I don't know if I had less patience when I got to reading The Calling but I found it a lot more disappointing. I may have come to it with the wrong expectations. The story occurs 15 years later and I was hoping it focused on Duncan like the first book focused on Maric and Loghain. Even taking into account that Duncan is much younger than when we meet him in the game, I didn't recognise him at all and didn't see either any evolution toward becoming the man we meet in DA. The character may as well have been named Bob the Grey Warden. (Then again, maybe I missed this side of him or misunderstood him in the game.........) Additionally, nearly all of the story occurs in one location -- the Deep Roads, which makes for a fairly repetitive scenery. The only bits I found interesting were echoes from the first book but they only carried the story so far, especially as Maric and his angsty angst started angstying on every other paragraph. Ah well. Time to go hunting for more trophies until it's time to play Dragon Age 2 ;)

Leave a comment

Course content, now CC-BY-NC

I added a notice to my previous courses notes to indicate that they are now available under the CC-BY-NC license. I don't know if it'll be in any way useful -- as I'm well aware the courses could use a huge amount of improvement (working on it!) -- but it seems worth doing.

Note to interested parties: If you're only looking for exercises to use in your own courses, don't worry about the license and just grab them. I would only humbly request, that you feel very free to also share back any exercise or resources you found useful to teach the basics -- I always struggle to find more! :-) Add a comment or contact me directly.

Leave a comment

Inventorium Education Symposium

A couple of weeks ago, I picked up an Inventorium flyer in Tog (wonder who left them there!), and I thought I would register/apply for their symposium in the Science Gallery, now tomorrow night, as the themes appear to touch on many of the education and tech topics that are close to my heart (here's a link to the PDF flyer). It all looks and sounds terribly interesting, and I'm looking forward to learn a few things.

I was kind of planning on going as an enthusiastic mostly-observer, but I must say after spending more time reading the Inventorium website, it's indeed likely to be the case. I don't know if the kind of ideas I have, more like opinions really, together with the occasional quirky endeavour, will be relevant for this "symposium". I have trouble mapping the language on their site to the approachable content of the flyer. Still -- I'm sure it'll be very interesting, and at least I'll learn how closely I should follow the Inventorium efforts over the next few years :-)

Leave a comment

Inventorium event, impressions A successful evening!

As planned I attended the Inventorium event yesterday. Thankfully the event content and atmosphere matched the flyer's tone, as opposed to the website's (guess I'm not the audience for that one!)

The evening started with nibbles and sort of cringe worthy "networking" exercises that felt quite a bit forced but... thanks to it I actually ended up chatting to someone with a very interesting background, a woman with a 20 year long career as a software developer who's now training to become a teacher. I wish we had had more time to chat and I'll be in touch, I have tons of questions! :-) So yeah, I can sneer all I want, but it looks like these networky thingies have some value -- for better or worse!

Overall I had a very good time and found the talks interesting, sometimes insightful, and other times even inspiring. The evening started with people introducing the Inventorium project, etc. Then there was a wonderful 30 minutes keynote from Jonathan Drori about digital businesses in general and educational digital businesses in particular. This was followed by 7 short talks, 10 minutes long, by various people interested in and involved in education in some way. The speakers included a teacher and a pupil, which I think brought a very important perspective (Aron's candid talk generated many smiles!).

Random highlights:

  • Brendan Tangney, who was the second to last speaker, showed us a graph that went a bit like this:
        + 2
       / \    _ _ _ _ + 4
      /	  \ /
     /     + 3
  1 +

with names such as 1. "New technology trigger", 2. "Peak of inflated expectations, 3. "Trough of disillusionment" and 4. "Plateau of productivity", x axis as time. When he asked the audience what stage we thought ICT in education was at, answers varied between 1, 2 and 3. Turns out everyone was right, kinda: we have an interesting issue in ICT in education, in that we keep looping from 1 to 3, and then instead of trying to figure out how to go through the "slope of enlightenment" (between 3 and 4) we just go back to 1 with the latest technological novelty. Considering how many people mentioned the iPad and its potential for this or that, I thought that point really hit home!

  • I knew about Camara's work in Africa, but I didn't know they were also getting involved in education in Ireland, providing refurbishing PCs to disadvantaged schools and teaching training! This is great!
  • Stephen Carey, the teacher, talked to us about the Suas "Bridge 2 College" program and the gap it attempts to fill. To illustrate his main point, that collaboration between students is the best way to learn, he showed us this wonderful picture of how they've rethought the classroom layout for the program. I wish I could find the exact same picture but this one gives an idea already -- it's impossible to simply stand at the front and blandly lecture.

Classroom pictures, the class is divided in smaller walled sections

  • Martin Owen showed us the toy for pre-schoolers his company is developing... and I want some of these tiles for myself, check out the videos!!

Very happy with my evening. I will be watching out for upcoming Inventorium events and the project's outputs.

Leave a comment | 2 so far

Archives