[PATCH 5 of 8] revlog: add revlog.empty()

Matt Mackall mpm at selenic.com
Mon Jun 3 15:27:20 CDT 2013


On Fri, 2013-05-31 at 10:19 -0700, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham at fb.com>
> # Date 1369964836 25200
> #      Thu May 30 18:47:16 2013 -0700
> # Node ID 37611b85f4af013a0e66aad75e8578cdf3247c79
> # Parent  036972b09c16295c000847ba359193858e7b3a4d
> revlog: add revlog.empty()

A more Pythonic way to do this would be __nonzero__().

object.__nonzero__(self)
        Called to implement truth value testing and the built-in
        operation bool(); should return False or True, or their integer
        equivalents 0 or 1. When this method is not defined, __len__()
        is called, if it is defined, and the object is considered true
        if its result is nonzero. If a class defines neither __len__()
        nor __nonzero__(), all its instances are considered true.
        
This is part of the reason we're currently using __len__, actually.

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list