Re: Working with Descriptors

2011-12-11 Thread Ian Kelly
On Sun, Dec 11, 2011 at 9:32 PM, Emeka wrote: > > Hello All, > > How do I get the __set__ to work here? > > import random > > class Die(object): >     def __init__(self, sides=6): >     self.sides = sides > >     def __get__(self, instance, owner): >     return int(random.random() * self.s

Working with Descriptors

2011-12-11 Thread Emeka
Hello All, How do I get the __set__ to work here? import random class Die(object): def __init__(self, sides=6): self.sides = sides def __get__(self, instance, owner): return int(random.random() * self.sides) + 1 def __set__(self, instance, value): instance._