Method default argument whose type is the class not yet defined

Chris Angelico rosuav at
Sun Nov 11 03:13:51 CET 2012

On Sun, Nov 11, 2012 at 12:13 PM, Steven D'Aprano
<steve+comp.lang.python at> wrote:
> Almost but not quite. I assume that, in a full Point class, you would
> want Point(0, 0) to count as false in a boolean context. (A "falsey"
> value, like None, [], 0.0, etc.)

I would not assume that. The origin is a point, just like any other.
With a Line class, you could deem a zero-length line to be like a
zero-element list, but Point(0,0) is more like the tuple (0,0) which
is definitely True. In any case, this would not even matter, beyond
unnecessary work; the bug would occur only if you seek the distance to
Point(0,0), at which point[1] the code would throw out the incoming
Point and go with the default of 0,0. So it'd result in the same


[1] Sorry, couldn't resist

More information about the Python-list mailing list