Python 3.10's cool new match statement

30 views
Skip to first unread message

Edward K. Ream

unread,
Apr 1, 2022, 9:39:09 AM4/1/22
to leo-editor
Python 3.10 supports the new match statement. Don't panic, match is a "soft" keyword.

Imo, this is the coolest addition to python since acyncio:

- Pep 634 describes the feature,
- Pep 635 gives the rationale,
- Pep 635 is a tutorial.

Leo issue #2541provides support for the required new ast parse-tree nodes.

I'm still trying to get my head around the "declarative" style of pattern matching. It might be possible to improve Leo's fast-read algorithm using this feature.

It is possible to (conditionally) use the match statement in Leo's code. The trick would be to put the new code in a separate file, say leoPython3.10.py. To use the new code, you would try to import functions from this file, falling back to legacy code if the import failed.

Edward

Zoom.Quiet

unread,
Apr 1, 2022, 9:08:09 PM4/1/22
to leo-e...@googlegroups.com
super, guido's new tutorial

Edward K. Ream <edre...@gmail.com> 于2022年4月1日周五 21:39写道:
> --
> You received this message because you are subscribed to the Google Groups "leo-editor" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/69769d3d-c9ba-4fb8-b20a-db807ac86637n%40googlegroups.com.



--
----------------
life is pathetic, go Pythonic. 人生苦短, Python当歌 ;-)
课: https://py.101.camp/
怼: https://du.101.camp/
俺: http://zoomquiet.io
许: http://creativecommons.org/licenses/by-sa/2.5/cn/
怒: 冗余不做,日子甭过!备份不做,十恶不赦.
KM keep growing environment culture which promoting organization learning ;-)

Edward K. Ream

unread,
Apr 2, 2022, 6:18:54 AM4/2/22
to leo-editor
On Fri, Apr 1, 2022 at 8:08 PM Zoom.Quiet <zoom....@gmail.com> wrote:
super,  guido's new tutorial

Glad you like it.  For the record, the tutorial is PEP 636, not 635 as I incorrectly said. Appendix A is a quick summary.

Edward
Reply all
Reply to author
Forward
0 new messages