Re: Descriptors vs Property

2016-03-19 Thread Ethan Furman
On 03/11/2016 09:59 PM, Veek. M wrote: A property uses the @property decorator and has @foo.setter @foo.deleter. A descriptor follows the descriptor protocol and implements the __get__ __set__ __delete__ methods. `property` is a descriptor combined with a decorator, so is a little more compl

Re: Descriptors vs Property

2016-03-15 Thread Thomas 'PointedEars' Lahn
Mark Lawrence wrote: > Please ignore 'PointedEars', Please ignore Mark Lawrence unless he has something on-topic to say. How does that feel, Mark? > every month or so for some weird reason The reason being obviously that the people to whose postings I happen to post a follow-up to do not post

Re: Descriptors vs Property

2016-03-14 Thread Rustom Mody
On Monday, March 14, 2016 at 9:06:01 PM UTC+5:30, Mark Lawrence wrote: > On 13/03/2016 13:20, Veek. M wrote: > > Thomas 'PointedEars' Lahn wrote: > > > Nobility lies in action, not in name. > --Surak > > > > Someone called Ned.B who i know elsewhere spoke on your behalf. I'm glad

Re: Descriptors vs Property

2016-03-14 Thread Mark Lawrence
On 13/03/2016 13:20, Veek. M wrote: Thomas 'PointedEars' Lahn wrote: Nobility lies in action, not in name. —Surak Someone called Ned.B who i know elsewhere spoke on your behalf. I'm glad to say I like/trust Ned a bit so *huggles* to you, and I shall snip. Also, sorry about the 'Steve

Re: Descriptors vs Property

2016-03-13 Thread Thomas 'PointedEars' Lahn
Veek. M wrote: > Thomas 'PointedEars' Lahn wrote: Nobility lies in action, not in name. —Surak > > Someone called Ned.B who i know elsewhere spoke on your behalf. I'm glad > to say I like/trust Ned a bit so *huggles* to you, and I shall snip. > > Also, sorry about the 'Steve' thi

Re: Descriptors vs Property

2016-03-13 Thread Veek. M
Thomas 'PointedEars' Lahn wrote: >>> Nobility lies in action, not in name. >>> —Surak Someone called Ned.B who i know elsewhere spoke on your behalf. I'm glad to say I like/trust Ned a bit so *huggles* to you, and I shall snip. Also, sorry about the 'Steve' thing - bit shady dragging in

Re: Descriptors vs Property

2016-03-13 Thread Thomas 'PointedEars' Lahn
Veek. M wrote: > > http://www.thecodingforums.com/threads/examples-of-ecmascipt-written-by-thomas-lahn.937812/ > > Examples of ECMAScipt written by Thomas Lahn > > Thomas is the forums best known critic of everyone else's attempts at > writing ECMAscript. I was wondering

Re: Descriptors vs Property

2016-03-13 Thread Veek. M
Thomas 'PointedEars' Lahn wrote: > Veek. M wrote: > >> Thomas 'PointedEars' Lahn wrote: I haven't read the descriptor protocol as yet. >>> You should. You should also trim your quotations to the relevant >>> minimum, and post using your real name. >> >> I don't take advice from people on U

Re: Descriptors vs Property

2016-03-13 Thread Thomas 'PointedEars' Lahn
Veek. M wrote: > Thomas 'PointedEars' Lahn wrote: >>> I haven't read the descriptor protocol as yet. >> You should. You should also trim your quotations to the relevant >> minimum, and post using your real name. > > I don't take advice from people on USENET who DON'T have a long history > of hel

Re: Descriptors vs Property

2016-03-12 Thread Veek. M
Thomas 'PointedEars' Lahn wrote: >> I haven't read the descriptor protocol as yet. > > You should. You should also trim your quotations to the relevant > minimum, and post using your real name. > I don't take advice from people on USENET who DON'T have a long history of helping ME - unless I'

Re: Descriptors vs Property

2016-03-12 Thread Thomas 'PointedEars' Lahn
Veek. M wrote: > Veek. M wrote: >> class TypedProperty(object): >> def __init__(self,name,type,default=None): >> self.name = "_" + name >> self.type = type >> self.default = default if default else type() >> >> def __get__(self,instance,cls): >> return geta

Re: Descriptors vs Property

2016-03-11 Thread Ian Kelly
On Fri, Mar 11, 2016 at 11:24 PM, Veek. M wrote: > Ian Kelly wrote: > >> On Fri, Mar 11, 2016 at 10:59 PM, Veek. M wrote: >>> Also, what's this bit: >>> self.default = default if default else type() >> >> If the default parameter has a truthy value, it gets set to >> self.default. Otherwise, the

Re: Descriptors vs Property

2016-03-11 Thread Chris Angelico
On Sat, Mar 12, 2016 at 5:24 PM, Veek. M wrote: >> Also, what's this bit: >> self.default = default if default else type() > But type() just gives me: > TypeError: type() takes 1 or 3 arguments > on py2,3 Check out the context of the original line of code and see what it's doing. It isn't the sam

Re: Descriptors vs Property

2016-03-11 Thread Veek. M
Ian Kelly wrote: > On Fri, Mar 11, 2016 at 10:59 PM, Veek. M wrote: >> A property uses the @property decorator and has @foo.setter >> @foo.deleter. >> >> A descriptor follows the descriptor protocol and implements the >> __get__ __set__ __delete__ methods. >> >> But they both do essentially the s

Re: Descriptors vs Property

2016-03-11 Thread Veek. M
Veek. M wrote: > A property uses the @property decorator and has @foo.setter > @foo.deleter. > > A descriptor follows the descriptor protocol and implements the > __get__ __set__ __delete__ methods. > > But they both do essentially the same thing, allow us to do: > foo = 10 > del foo > x = foo >

Re: Descriptors vs Property

2016-03-11 Thread Ian Kelly
On Fri, Mar 11, 2016 at 10:59 PM, Veek. M wrote: > A property uses the @property decorator and has @foo.setter > @foo.deleter. > > A descriptor follows the descriptor protocol and implements the __get__ > __set__ __delete__ methods. > > But they both do essentially the same thing, allow us to do:

Re: Descriptors vs Property

2016-03-11 Thread Chris Angelico
On Sat, Mar 12, 2016 at 4:59 PM, Veek. M wrote: > A property uses the @property decorator and has @foo.setter > @foo.deleter. > > A descriptor follows the descriptor protocol and implements the __get__ > __set__ __delete__ methods. > > But they both do essentially the same thing, allow us to do: >