xuv's notebook

Side notes, howtos and random bits of information related to Julien Deswaef's projects

User Tools

Site Tools


workshops:python_with_glue

This is an old revision of the document!


Python with glue

https://hackerspace.be/Python_Workshop_with_Glue

BPython : cmdline python interpreter improved (w/ auto-completion, colored syntax,…)

2**3 # is 2 power 3
type(s) # returns the type of object s

mutable types and non-mutable types

Basic types are non-mutable: Int, Float, Long, String, Tuple
Mutable types: List (Array is a type of list)

0b00000001 # represents a binary number

Dictionaries

You can put any type of object in a dictionary (not so much as a key, but as a value). A function can be put as a value in a dictionary.

PPrint

A python library for pretty printing.

OOP

# Creating a class
class Hello:
    pass
 
#  Or the now official way (compatible with python3)
class Hello(object):
    pass
 
h  = Hello() # Creates an instance of the class Hello
 
h.value1 = 23 # adds an attributes to the instance h
 
Hello.value2 = 45 # adds an attribute to the class and all its instances. 

You can add attributes and methods on the fly.

workshops/python_with_glue.1327242003.txt.gz · Last modified: 2012/01/22 15:20 by 62.235.231.149