Why are Python printf examples fiction?


All the Python learning pages say that printf'ing must be done:

for x in range(0, 3):
    print "We're on time %d" % (x)

But, in pyCharm, I have to use brackets:

print("age = ",24)

for x in range(0,5) :

Why does pycharm require this break from examples?
It will seem lame to try and explain that to a student.

Who is Participating?
peprConnect With a Mentor Commented:
Just speculation. Python 2 uses print without parentheses (print is a command -- part of the syntax). Python 3 changes that, and print is implemented as a built-in function and it requires parentheses.

Later versions of Python 2 allows to import new syntax of print  with parentheses (that was back-ported from Python 3).

It is possible to write a module or program that can be executed both from Python 2 and Python 3 implementations. The version is detected by the module/program, and the functionality is implemented using both alternatives internally.

As Python 2 was considered to be obsolete in future, pyCharm authors may have chosen the print('with parentheses') syntax as a single one. It means that obsoleting Python 2 in future would not obsolete the pyCharm IDE. This also means that the third party extensions for pyCharm are universal independently on whether it runs or on Python 2, or on Python 3. From another point of view, the extensions are not to be broken when switching to Python 2 to Python 3.
Dave BaldwinConnect With a Mentor Fixer of ProblemsCommented:
Most of the languages I know of require function arguments to be in parenthesis even for 'built-in' functions.
beavoidAuthor Commented:

in .py files compiled in a console, parentheses are also needed?
Then why do the books exclude parentheses?

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

beavoidAuthor Commented:
If I start teaching local kids to do coding, is Pycharm the best way? (obviously is)
What are professional python projects done in?
Just curious
peprConnect With a Mentor Commented:
In my opinion, whatever text editor that supports smart indentation and syntax highlighting is good for Python. Simple ones may be better at the beginning. They should not be confused -- the editor/IDE is not essential for the functionality of the program. Even Python's IDLE may be fine for kids. It also depends on whether the "kids" are 4, 10, 16, or 70.
beavoidAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.