• dreugeworst@lemmy.ml
    link
    fedilink
    English
    arrow-up
    3
    ·
    11 hours ago

    as someone who would also reach for a state machine when doing simple parsing… what’s the better alternative in python?

    • lectricleopard@lemmy.world
      link
      fedilink
      English
      arrow-up
      1
      ·
      4 hours ago

      A loop and a data structure to hold the result of parsing. The data structure will have a state you can interrogate. No need to build a state machine to explicitly name each way the parsing can develop.