Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ Added simple test for descriptor protocol
- Loading branch information
Christian Iversen
committed
Aug 17, 2013
1 parent
d1e02f3
commit 72668a3
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |