Python Workshop

From Hackerspace Brussels
Jump to: navigation, search


Python Workshop
Sat 26 Sep 2009 14:00
till Sat 26 Sep 2009 20:00
Bicycle-repairman1.jpg
What:
python workshop,, by User:Fs111
Tagline:
def workshop(python_at_hsb)
Where:
HSB Brussels,Belgium
Cost:
5 EUR (for non-members)
Who:
HSB
URL:
Python_Workshop


What[edit]

This will be a beginners workshop, things I (fs111) want to cover:

  • Brief introduction in the who, what and where in python
  • Hello World and the interactive interpreter
  • control structures
  • built-in types (numbers, strings, lists, dicts, sets etc.) and higher level functions
  • input/output
  • module system (imports)
  • objects and classes and types
  • documentation system
  • neat little tricks and features you should know (generators, list comprehension, slicing)
  • some modules from the standard lib that you should know (OS interface, filesystem, option parsing, xml?, network stuff etc.)
  • Q/A all the time of course
  • free style hacking afterwards
  • Python egg
  • Paster

How long will the workshop last?[edit]

I really don't know. I try to cover the stuff mentioned above and then we can go into freestyle hacking, where we help each other out I guess. As long we do not run out of mate we can go on :-)


Stuff you need[edit]

I will use the latest release of the Python 2.x series which is 2.6 right now. 3.x is out already for some time but the adoption is low and a big number of 3rdd party modules are not ported yet. So what I would expect from you is that you have the following installed:

  • python 2.6, which can be downloaded here
  • a text editor of choice, anything will do, I use vim. Tips for vim and Python here.
  • a shell

Participants[edit]

Put your name here if you are coming:

WhoCommentPresent
fs111This space is intentionally left blankyes
ErikThis space is intentionally left blankyes
SandbThis space is left blank intentionallyyes
KoertThis space is left blank intentionallyyes
nicodacheis This left intentionally space blank (and #@! whoever changed my comment :-))yes
TazoThis space is left blank intentionallyyes
MarcThis space is left blank intentionallyyes
Jobjwtf copy/past generationyes
Skawouternot 100% shure jetyes
tvlooycan haz python?yes
Xflameyes
zoobabno comment
U_go yes
Thomasyes




Readline[edit]

# Add auto-completion and a stored history file of commands to your Python
# interactive interpreter. Requires Python 2.0+, readline. Autocomplete is
# bound to the Esc key by default (you can change it - see readline docs).
#
# Store the file in ~/.pystartup, and set an environment variable to point
# to it:  "export PYTHONSTARTUP=/home/user/.pystartup" in bash.
#
# Note that PYTHONSTARTUP does *not* expand "~", so you have to put in the
# full path to your home directory.

import atexit
import os
import readline
import rlcompleter
readline.parse_and_bind('tab: complete')
historyPath = os.path.expanduser("~/.pyhistory")

def save_history(historyPath=historyPath):
    import readline
    readline.write_history_file(historyPath)

if os.path.exists(historyPath):
    readline.read_history_file(historyPath)

atexit.register(save_history)
del os, atexit, readline, rlcompleter, save_history, historyPath

Hello World[edit]

#!/usr/bin/env python
# -*- coding: utf-8 -*-

print "Hello HSB"


spawning processes[edit]

 import subprocess

don't try popen, os.system, or whatever else

Presentation[edit]

Here is the pdf of the quick introduction from the beginning of the workshop:

File:Python-workshop.pdf