Checking the boolean value of a collection

Fredrik Lundh fredrik at
Sat Sep 13 16:11:15 CEST 2008

Marco Bizzarri wrote:

> class FolderInUse:
>     def true_for(self, archivefolder):
>         return any([instance.forbid_to_close(archivefolder) for instance in
>             self.core.active_outgoing_registration_instances()])
> Is this any better? The true_for name does not satisfy me a lot...

well, "true_for" is indeed pretty inscrutable, but I'm not sure that 
would be the first thing I'd complain about in that verbose mess...

(when you pick method names, keep in mind that the reader will see the 
context, the instance, and the arguments at the same time as they see 
the name.  there's no need to use complete sentences; pick short short 
descriptive names instead.)


More information about the Python-list mailing list