Skip to content

Pattern matching via Python's codec options

License

Notifications You must be signed in to change notification settings

caccavale/pattern_match

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pattern_match

pattern_match is an abuse of some change to python syntax added in 3.8 with the walrus operator :=. It is code that has been carved out of Panoramix and not at all my original work.

kolinko built Tilde (here as pattern_match) which adds the ~ operator for pattern matching. A ~ denotes a pattern to be matched and then replaced with a series of := operators underneath. Because of this, Python 3.8 is required.

Installation:

git clone https://github.com/caccavale/pattern_match

Usage:

Currently, encodings are only available in imported modules so trying to run a file using pattern_match will fail:

$ python imports_pattern_match.py
File "imports_pattern_match.py", line 1
SyntaxError: encoding problem: pattern_match

To fix this, have an another file that imports the pattern_match using file:

$ cat wrapper.py
import imports_pattern_match
$ python wrapper.py

About

Pattern matching via Python's codec options

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%