<p><span class="h-card"><a href="https://mastodon.social/@whitequark" class="u-url mention">@<span>whitequark</span></a></span> <span class="h-card"><a href="https://mastodon.social/@whitequark" class="u-url mention">@<span>whitequark</span></a></span> What I really like is matching directly object or property types in the case statements. ex:</p><p>```python<br />match fruit_obj:<br /> case Apple(color=Red()):<br /> print(&quot;I&#39;m a red apple&quot;)<br /> case Apple():<br /> print(&quot;I&#39;m an apple&quot;)<br /> case Orange():<br /> print(&quot;I&#39;m an orange&quot;)<br /> case _:<br /> print(f&quot;Unknown fruit type: {type(fruit_obj)}&quot;)<br />```</p><p>P.S. match case statements were introduced in 3.10.</p>
Reply