[Python-ideas] Match statement brainstorm

Greg Ewing greg.ewing at canterbury.ac.nz
Mon May 30 08:52:22 EDT 2016

Michael Selik wrote:
> On Sun, May 29, 2016 at 7:00 PM Greg Ewing <greg.ewing at canterbury.ac.nz 
> <mailto:greg.ewing at canterbury.ac.nz>> wrote:
>     My feeling is that for any well-designed object they
>     should be compatible. If an object has a constructor
>     keyword arg and an attribute with the same name but
>     they mean different things, that object is confusing
>     to begin with.
> What about Fraction -- it has ``numerator`` and ``denominator`` for 
> keyword arguments, but also has an extra stuff like ``real`` and 
> ``imag`` inherited from Complex?

All of those names are distinct, so there's no problem
there. All of them would be usable as keywords when unpacking.
Additionally you would be able to unpack 'numerator' and
'denominator' positionally, because the constructor accepts
those positionally.


More information about the Python-ideas mailing list