code style and readability [was: Re: Checking the boolean value of a collection]

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Sat Sep 13 18:51:13 CEST 2008


Larry Bates a écrit :
> Bruno Desthuilliers wrote:
>> Bruno Desthuilliers a écrit :
>>> Larry Bates a écrit :
>>> (snip)
>>>> IMHO it reads better if you use the __call__ method of the class to 
>>>> return the value 
>>>
>>> IMHO, it makes no sense at all to abuse the __call__ magic method here.
>>
>> Sorry - after a more careful re-read of other posts in the thread, it 
>> might make sense, given the use case :
>>
>> condition = FolderInUse(core)
>> if condition.true_for(folder):
>>    # code here
>>
>>
>> but then, a plain function (or a partial) might be even better - that 
>> is, if the FolderInUse class doesn't have other responsabilities.
>>
>>
> 
> Sorry but I respectfully disagree that this is "abuse" of the __call__ 
> method. 

As long as we respectfully agree to disagree...

!-)




More information about the Python-list mailing list