[Python-3000] Use case for generics
Greg Ewing
greg.ewing at canterbury.ac.nz
Sun May 14 04:06:27 CEST 2006
Talin wrote:
> r = Rectangle( x, y, w, h )
> r = Rectangle( minpos, maxpos )
> r = Rectangle( position, size )
This sort of thing is better done in Python using
keyword arguments:
Rectangle(left = x, top = y, width = w, height = h)
Rectangle(topleft = (x, y), size = (w,h))
Rectangle(topleft = (x0, y0), botright = (x1, y1))
This is actually more flexible, because if implemented
appropriately it also allows things like
Rectangle(size = (w, h), botright = (x, y))
which I've never seen anyone bother to provide in
a statically-typed Rectangle constructor -- it's
just too tedious to implement all the possible
combinations as separate function signatures.
--
Greg
More information about the Python-3000
mailing list