Azure-Samples/virtual-machines-python-manage

compatibility issue with python 2.7.14

Closed this issue · 2 comments

in example.py on line 231
print('A VM operation failed:', traceback.format_exc(),sep='\n') is causing SyntaxError as sep param not compatible with 2.7

In Python 2.x, unlike in Python 3.x, print is not a function, but a statement described here. Basically it means that print is treated as a keyword (like for) and is not as powerful as the print function that you know from Python 3.x. In particular, it does not support the sep keyword argument.

Using in the beggining of the file:

from __future__ import print_function

Reference: https://stackoverflow.com/questions/26922245/python-2-7-3-sep-argument-showing-error

(@marcelo-salvatori I edited your text to put a python code block instead, for the underscore issue)

For some reason, I missed the initial issue in April :(. I will update the sample accordingly. Thanks!