util.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:asttokens 作者: gristlabs 项目源码 文件源码
def expect_token(token, tok_type, tok_str=None):
  """
  Verifies that the given token is of the expected type. If tok_str is given, the token string
  is verified too. If the token doesn't match, raises an informative ValueError.
  """
  if not match_token(token, tok_type, tok_str):
    raise ValueError("Expected token %s, got %s on line %s col %s" % (
      token_repr(tok_type, tok_str), str(token),
      token.start[0], token.start[1] + 1))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号