You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While browsing through the example scripts in the docs, I noticed that the Python scripts seem to utilize Python 2 print statements. This could potentially lead to errors when running these scripts in a Python 3 environment. So not really a big issue and something that can be easily resolved.
One of the scripts uses the following structure:
# /examples/Program-examples/01_Python/primes.py#! /usr/bin/env pythonimportdatetimeimporttimeimportsysdefprint_time(str):
now=time.time()
st=datetime.datetime.fromtimestamp(now).strftime('%Y-%m-%d %H:%M:%S')
printstr, streturnint(now)
defask_int(prompt, retries=3):
whileTrue:
num=int(input(prompt))
ifnum>1:
returnnumelse:
print"Please enter an integer which is bigger than one."retries-=1ifretries<=0:
print('Too many attempts, try again later.')
sys.exit()
The print statements in this script are written in the Python 2 style, without parentheses, which would lead to syntax errors in Python 3.
Possible fixes are:
Update the Scripts: The scripts could be updated to Python 3. This would involve minor changes, such as modifying print statements to use parentheses.
Specify Python Version in Documentation: Alternatively, if maintaining the scripts in Python 2 is preferable, it would be beneficial to clearly specify in the documentation that these scripts are intended to be run with Python 2.
The text was updated successfully, but these errors were encountered:
While browsing through the example scripts in the docs, I noticed that the Python scripts seem to utilize Python 2 print statements. This could potentially lead to errors when running these scripts in a Python 3 environment. So not really a big issue and something that can be easily resolved.
One of the scripts uses the following structure:
The
print
statements in this script are written in the Python 2 style, without parentheses, which would lead to syntax errors in Python 3.Possible fixes are:
The text was updated successfully, but these errors were encountered: