【问题标题】:How to fetch method call using a custom migration fixer in lib2to3?如何使用 lib2to3 中的自定义迁移修复程序获取方法调用?
【发布时间】:2013-10-07 14:08:16
【问题描述】:

我正在尝试为 lib2to3 创建自定义迁移修复程序。固定器的想法是获取特定的构造,例如:

a.b()

我们曾尝试使用名为find_pattern.py 的脚本,但到目前为止还没有成功。输出如下:

power< 'a' trailer< '.' 'b' > trailer< '(' ')' > >

但不幸的是,正如您可能已经猜到的那样 - 这不起作用。我们应该为BaseFix 使用什么模式?

【问题讨论】:

    标签: python migration


    【解决方案1】:

    这是需要准备的模式。

    PATTERN = '''
        power< head=any+
         trailer< '.' method=any >
         parens=trailer< '(' tail=[argument | arglist] ')'>
    
        >
    '''
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-11-04
      • 2023-03-26
      • 2017-11-23
      • 1970-01-01
      • 1970-01-01
      • 2015-09-25
      • 1970-01-01
      • 2018-07-14
      相关资源
      最近更新 更多