On Mar 23, 4:14 pm, Paddy <[EMAIL PROTECTED]> wrote:
> On Mar 23, 3:53 pm, John Nagle <[EMAIL PROTECTED]> wrote:
>
> >    What's the cheapest way to test for an empty dictionary in Python?
>
> >         if len(dict.keys() > 0) :
>
> > is expensive for large dictionaries, and makes loops O(N^2).
>
> >                                         John Nagle
>
> As others have stated, if <container object>: is false for built-in
> container types such as  dicts, lists, sets, tuples,...
> Its nice to make any of your own container types follow the same
> convention too.
>
> - Paddy.

I missed out *empty* didn't I.
Its false for empty container types.

- Paddy.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to