Python pypeg:str或List是什么意思?

Python pypeg:str或List是什么意思?,python,parsing,Python,Parsing,试图像这样解析表达式 名称(arg1、arg2…) 所以我试着: from pypeg2 import * class Type (str): grammar = attr ('type', re.compile (r'[a-z]+')) class args (List): grammar = maybe_some ( csl (word) ) class Gen (str): grammar = Type, '(', args, ')' 首先我试着从列表中导出

试图像这样解析表达式 名称(arg1、arg2…)

所以我试着:

from pypeg2 import *

class Type (str):
    grammar = attr ('type', re.compile (r'[a-z]+'))

class args (List):
    grammar = maybe_some ( csl (word) )

class Gen (str):
    grammar = Type, '(', args, ')'
首先我试着从列表中导出Gen,但后来我得到了 语法中的GrammarTypeError:'('

我不明白从“str”派生或从“List”派生意味着什么。在哪里可以找到解释?

尝试以下更改:

from __future__ import unicode_literals, print_function
import re
from pypeg2 import *

class Type (str):
    grammar = attr ('type', Symbol)

class args (List):
    grammar = maybe_some ( csl (word) )

class Gen (str):
    grammar = Type, '(', args, ')'

teste = "name(arg1,arg2, arg3)"

k = parse(teste, Gen)

print(k)

您对文档的哪一部分有问题?我试图按照查找列表的示例进行操作。它似乎与我尝试的内容相同,我不明白为什么我的文档在“(”上出现错误,我能看到的唯一区别是我使用了“(”和使用的示例”{'@nbecker您使用了Python3吗?或者,如果您使用的是python2.7,您需要从将来的模块中导入unicode_文本