Skip to content

ArcletProject/NEPattern

Repository files navigation

NEPattern

Licence PyPI PyPI - Python Version codecov

NEPattern (Not-Enough-Pattern) ๆ˜ฏไธ€ไธช้ซ˜ๆ•ˆ็š„่ดŸ่ดฃ็ฑปๅž‹้ชŒ่ฏไธŽ็ฑปๅž‹่ฝฌๆข็š„ๅบ“๏ผŒ็‹ฌ็ซ‹่‡ช Alconna

็ฎ€ๅ•ๅฎžไพ‹

from nepattern import Pattern


pat = Pattern(str).accept(int).convert(lambda _, x: str(x))
assert pat.execute(13).success
assert pat.execute(42).value() == '42'
assert not pat << 13.0

็‰น็‚น

  • ้ซ˜ๆ•ˆ็š„็ฑปๅž‹่ฝฌๅŒ–ๅŠŸ่ƒฝ
  • ๅคš็ง้ข„็ฝฎ็š„ๅฎžไพ‹
  • ่‰ฏๅฅฝ็š„ typing ๆ”ฏๆŒ
  • ่‡ช็”ฑ็š„็ŽฏๅขƒๆŽงๅˆถ