Skip to content

Commit

Permalink
+ Added simple test for descriptor protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Iversen committed Aug 17, 2013
1 parent d1e02f3 commit 72668a3
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/class/descriptor1.py
@@ -0,0 +1,24 @@
counter = 10

def count():
global counter
counter += 1
return counter

class Desc(object):

def __get__(self, k, t):
# print k, t
print type(self) == Desc
print k <> None
print t == Foo
global counter
return lambda: count()

class Foo(object):

d = Desc()

f = Foo()
print f.d()
print Foo.d()

0 comments on commit 72668a3

Please sign in to comment.