Re: is_whatever_you_are_testing_for as method or property?

2014-12-15 Thread Mateusz Loskot
On 13 December 2014 at 12:24, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Mateusz Loskot wrote: On 12 December 2014 at 12:26, Chris Angelico ros...@gmail.com wrote: On Fri, Dec 12, 2014 at 10:21 PM, Mateusz Loskot mate...@loskot.net wrote: I've got several cases which are not

Re: is_whatever_you_are_testing_for as method or property?

2014-12-13 Thread Steven D'Aprano
Mateusz Loskot wrote: On 12 December 2014 at 12:26, Chris Angelico ros...@gmail.com wrote: On Fri, Dec 12, 2014 at 10:21 PM, Mateusz Loskot mate...@loskot.net wrote: I've got several cases which are not obvious to me. For instance, class Foo has a boolean attribute, read-write, which I see

Re: is_whatever_you_are_testing_for as method or property?

2014-12-12 Thread Mateusz Loskot
On 11 December 2014 at 19:20, Chris Angelico ros...@gmail.com wrote: On Fri, Dec 12, 2014 at 4:34 AM, Mateusz Loskot mate...@loskot.net wrote: If a class member function simply tests something and returns a b::oolean call it def is_whatever_you_are_testing_for(): pass like 'is_even'.

Re: is_whatever_you_are_testing_for as method or property?

2014-12-12 Thread Chris Angelico
On Fri, Dec 12, 2014 at 10:21 PM, Mateusz Loskot mate...@loskot.net wrote: I've got several cases which are not obvious to me. For instance, class Foo has a boolean attribute, read-write, which I see a couple of realisations for possible: 0) Attribute only. class Foo: pass Foo().default

Re: is_whatever_you_are_testing_for as method or property?

2014-12-12 Thread Mateusz Loskot
On 12 December 2014 at 12:26, Chris Angelico ros...@gmail.com wrote: On Fri, Dec 12, 2014 at 10:21 PM, Mateusz Loskot mate...@loskot.net wrote: I've got several cases which are not obvious to me. For instance, class Foo has a boolean attribute, read-write, which I see a couple of realisations

Re: is_whatever_you_are_testing_for as method or property?

2014-12-12 Thread Chris Angelico
On Sat, Dec 13, 2014 at 8:03 AM, Mateusz Loskot mate...@loskot.net wrote: On 12 December 2014 at 12:26, Chris Angelico ros...@gmail.com wrote: On Fri, Dec 12, 2014 at 10:21 PM, Mateusz Loskot mate...@loskot.net wrote: I've got several cases which are not obvious to me. For instance, class Foo

Re: is_whatever_you_are_testing_for as method or property?

2014-12-12 Thread Mateusz Loskot
On 12 December 2014 at 22:14, Chris Angelico ros...@gmail.com wrote: On Sat, Dec 13, 2014 at 8:03 AM, Mateusz Loskot mate...@loskot.net wrote: On 12 December 2014 at 12:26, Chris Angelico ros...@gmail.com wrote: On Fri, Dec 12, 2014 at 10:21 PM, Mateusz Loskot mate...@loskot.net wrote: I've

is_whatever_you_are_testing_for as method or property?

2014-12-11 Thread Mateusz Loskot
Hi, I have been looking at various places to answer this dilemma: If a class member function simply tests something and returns a b::oolean call it def is_whatever_you_are_testing_for(): pass like 'is_even'. Should I define it as a classic method def is_even(self): pass or as a

Re: is_whatever_you_are_testing_for as method or property?

2014-12-11 Thread Chris Angelico
On Fri, Dec 12, 2014 at 4:34 AM, Mateusz Loskot mate...@loskot.net wrote: If a class member function simply tests something and returns a b::oolean call it def is_whatever_you_are_testing_for(): pass like 'is_even'. Should I define it as a classic method def is_even(self): pass

Re: is_whatever_you_are_testing_for as method or property?

2014-12-11 Thread Ethan Furman
On 12/11/2014 09:34 AM, Mateusz Loskot wrote: def is_whatever_you_are_testing_for(): pass like 'is_even'. Should I define it as a classic method def is_even(self): pass or as a property @property def is_even(self): pass So, a classic method or a property, which

Re: is_whatever_you_are_testing_for as method or property?

2014-12-11 Thread Ben Finney
Chris Angelico ros...@gmail.com writes: A property should be used if what you're creating is virtually an attribute. Methods are attributes. Are you distinguishing here between “callable attribute” versus “non-callable attribute”? -- \ “Repetition leads to boredom, boredom to

Re: is_whatever_you_are_testing_for as method or property?

2014-12-11 Thread Devin Jeanpierre
On Thu, Dec 11, 2014 at 1:33 PM, Ben Finney ben+pyt...@benfinney.id.au wrote: Chris Angelico ros...@gmail.com writes: A property should be used if what you're creating is virtually an attribute. Methods are attributes. Are you distinguishing here between “callable attribute” versus

Re: is_whatever_you_are_testing_for as method or property?

2014-12-11 Thread Chris Angelico
On Fri, Dec 12, 2014 at 8:33 AM, Ben Finney ben+pyt...@benfinney.id.au wrote: Chris Angelico ros...@gmail.com writes: A property should be used if what you're creating is virtually an attribute. Methods are attributes. Are you distinguishing here between “callable attribute” versus