Search code examples
pythonpylint

Why Pylint says print('foo', end='') is an invalid syntax?


This very simple code:

#!/usr/bin/python3
print('foo', end='')

Makes Pylint unhappy (both on Python2 and Python3):

pylint ./pylint.py
No config file found, using default configuration
************* Module pylint
E:  2, 0: invalid syntax (syntax-error)

Why?


Solution

  • I got this error when running pylint. But my pylint only had support for python2. So it errored:

    $ pylint foo.py 
    No config file found, using default configuration
    ************* Module foo
    E:  2, 0: invalid syntax (syntax-error)
    

    So I did pip3 install pylint.

    And then it all worked (or at least it got past the syntax error):

    $ python3 -m pylint foo.py  | head
    No config file found, using default configuration
    ************* Module foo
    C:  1, 0: Black listed name "foo" (blacklisted-name)
    C:  1, 0: Missing module docstring (missing-docstring)
    .....
    

    See here for more info on pylint for python2 and 3 in one system: https://askubuntu.com/questions/340940/installing-pylint-for-python3-on-ubuntu