Pythonic way to implement a tokenizer

前端 未结 12 730
青春惊慌失措
青春惊慌失措 2020-12-30 07:11

I\'m going to implement a tokenizer in Python and I was wondering if you could offer some style advice?

I\'ve implemented a tokenizer before in C and in Java so I\'m

12条回答
  •  不知归路
    2020-12-30 07:27

    "Is there a better alternative to just simply returning a list of tuples?"

    That's the approach used by the "tokenize" module for parsing Python source code. Returning a simple list of tuples can work very well.

提交回复
热议问题