2

I am working together on Python code with another beginning coder. Now we both have Python 3.8.2 installed. He is working on MAC and I am working on windows. We both work from Visual Studio Code and have the same Python extension installed (v 2020.3.71113 (31 March 2020) ).

The problem occurs when I define the type of parameters, such as in the following code:

def printing(name: str):
    print("This is your name: " + name)

printing("Mike")

On my computer this simply returns: This is your name: Mike, as I would expect.

But on his computer it throws a SyntaxError:

File ""File location"", line 1
    def printing(name: str):
                     ^
SyntaxError: invalid syntax

Now when we change the function to def printing(name): and leave all the rest unchanged, the error does not occur.

Any ideas why this happens and how we can let his computer work with defined types of parameters?

  • 2
    Can you confirm which python version you using by running `python --version`? – sedavidw Apr 01 '20 at 14:24
  • You take that windows computer, burn it with fire, get _anything_ else and continue. – garglblarg Apr 01 '20 at 14:25
  • @sedavidw Seems to be a very valid question. On my computer it says 3.8.2 but on his terminal it says 2.7. Even though his visual studio code shows 3.8.2 on the bottom. Also, when he opens his shell it says 3.8.2. I reckon this might be a solution: https://stackoverflow.com/questions/3819449/how-to-uninstall-python-2-7-on-a-mac-os-x-10-6-4 –  Apr 01 '20 at 14:29
  • @Steven yeah I suspect that you're not using the python version you think are. I would recommend using a python virtual env (it's dangerous to touch system level pythons). – sedavidw Apr 01 '20 at 14:44
  • @sedavidw We also found another work around. When the code is run in output, it produces the error. But when it is run in terminal it does not. –  Apr 01 '20 at 15:10
  • 1
    @Steven right this goes back to the theory that you're not running the python version you think you are. The terminal is probably running a different version of python than your IDE – sedavidw Apr 01 '20 at 17:22

0 Answers0