Commit 5e0bfd08 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Went down the rabit hole again that is descriptors especially on 'type'

parent e734cdb7
# expected: fail
# - I'm not sure how this is supposed to work
# I guess the __name__ attribute on classes is weird?
# - type.__name__ is a descriptor
class C(object):
pass
print C.__name__
print C.__module__
# print C.__dict__.keys() # __name__ doesn't appear!
# print dir(C) # __name__ doesn't appear!
c = C()
print c.__name__ # this should err
# expected: fail
# - inheritance not implemented
class C(object):
x = 1
class D(C):
pass
d = D()
# When going from an instance, looking through the classes should look at base classes:
print d.x
# But also when doing instance-level lookups!
print D.x
print D.__dict__
# expected: fail
# - descriptors not implemented yet
class D(object):
def __get__(self, instance, owner):
print "get", instance, owner
return 1
def __set__(self, instance, value):
print "set", instance, value
class C(object):
d = D()
print C.d
print C().d
c = C()
c.d = 2
print c.d
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment