[merge] LazyFactory
John Arbash Meinel
john at arbash-meinel.com
Wed Aug 16 03:45:27 BST 2006
Robert Collins wrote:
> On Tue, 2006-08-15 at 13:59 +0200, Adeodato Simó wrote:
>> * Robert Collins [Tue, 15 Aug 2006 14:16:17 +1000]:
>>
>>> I think 'registry.is_first_entry(an_entry)' is much clearer than
>>> 'bool(self._dict)'
>> Would you approve registry.is_empty() instead? Doesn't seem to me like
>> the function needs the "an_entry" argument.
>
> If its internal to the object, using 'if not len(self._dict)' would be
> ok too - its much more clear than casting to bool.
>
> Rob
>
Interestingly, PEP8 says to use implicit bool conversion, rather than len().
http://www.python.org/dev/peps/pep-0008/
- For sequences, (strings, lists, tuples), use the fact that empty
sequences are false.
Yes: if not seq:
if seq:
No: if len(seq)
if not len(seq)
Now, it doesn't specifically talk about dictionaries there. But that is
why I was doing:
if self._first_is_default and not self._dict:
# set the default
John
=:->
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060815/2b51e1ab/attachment.pgp
More information about the bazaar
mailing list