How do I get Pyflakes to ignore a statement?

前端 未结 7 806
南方客
南方客 2020-11-29 20:33

A lot of our modules start with:

try:
    import json
except ImportError:
    from django.utils import simplejson as json  # Python 2.4 fallback.
         


        
7条回答
  •  -上瘾入骨i
    2020-11-29 21:05

    I know this was questioned some time ago and is already answered.

    But I wanted to add what I usually use:

    try:
        import json
        assert json  # silence pyflakes
    except ImportError:
        from django.utils import simplejson as json  # Python 2.4 fallback.
    

提交回复
热议问题