[Python-ideas] Match statement brainstorm

Ethan Furman ethan at stoneleaf.us
Fri May 27 22:34:41 EDT 2016


On 05/27/2016 06:32 PM, Greg Ewing wrote:
> Nikolaus Rath wrote:
>
>> class Point:
>>      def __init__(self, y, x):
>>          self.y = y
>>          self.x = x
>>
>> would your first example assign x == obj.x or x = obj.y?
>
> The intention is that positional args in the pattern
> correspond to positional args in the object's constructor.
> To make that work, there will have to be some protocol for
> reversing the construction of an object.

Meaning we can *only* match on constructor arguments?  What about 
attributes that are not set in the constructor, are we just out of luck 
for those?

--
~Ethan~



More information about the Python-ideas mailing list