Mercurial > hg > config
annotate python/bind.py @ 263:7b15ed0b372c
add a sample to bind to an instance, stub
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Fri, 15 Feb 2013 15:18:31 -0800 |
parents | |
children | efeb2cc78f30 |
rev | line source |
---|---|
263
7b15ed0b372c
add a sample to bind to an instance, stub
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
7b15ed0b372c
add a sample to bind to an instance, stub
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
2 |
7b15ed0b372c
add a sample to bind to an instance, stub
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
3 """ |
7b15ed0b372c
add a sample to bind to an instance, stub
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
4 illlustrate e.g. method bind for python |
7b15ed0b372c
add a sample to bind to an instance, stub
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
5 """ |
7b15ed0b372c
add a sample to bind to an instance, stub
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
6 |
7b15ed0b372c
add a sample to bind to an instance, stub
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
7 class Foo(object): |
7b15ed0b372c
add a sample to bind to an instance, stub
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
8 |
7b15ed0b372c
add a sample to bind to an instance, stub
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
9 @classmethod |
7b15ed0b372c
add a sample to bind to an instance, stub
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
10 def create(cls): |
7b15ed0b372c
add a sample to bind to an instance, stub
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
11 """create an instance and bind a method onto foo""" |
7b15ed0b372c
add a sample to bind to an instance, stub
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
12 |
7b15ed0b372c
add a sample to bind to an instance, stub
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
13 |
7b15ed0b372c
add a sample to bind to an instance, stub
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
14 def foo(self): |
7b15ed0b372c
add a sample to bind to an instance, stub
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
15 print "Foo!" |
7b15ed0b372c
add a sample to bind to an instance, stub
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
16 |