[Python] question regarding print()


This is weird, I wonder if someone can explain it to me.
Why is the print() function behavior different when using format or not?

a = 1
b = 2

print("Value a: ",a)
print("Value b: ",b)
print("a: {0}, b: {1}".format(a,b))

result of the above code is this:

Why does it print brackets in the first two lines and not the third one?

How can I configure RhinoPython to disregard “from future import print” or whtaver it is.
I want to use Brackets always when I print and not show them in the command line.


the upper 2 prints are printing a tuple object defined after the print statement
the lower prints a string


Here’s an example of printing a list:

Does that make sense?

Hi Wilem,

It does make sense, but why printing print(a,a) would give you again tuple.

See Python3

See IronPython

How can I make it work the same way?

Yes, how print works has changed in Python 3.

from __future__ import print function

If you really need to be P3 compatible


Don’t ask me, I never used it. All I know is that print changed from a statement to a function in P3. You might Google around and see how to correctly import it - if it is implemented in IronPython

1 Like

I think that __future__ module is for Python3 to copy the behavior of Python2.7 (ironpython).

And I would like it the other way around :frowning:

No, that’s not it, it’s to have Python 3 behavior in previous versions…

I guess I just have to get used to not putting everything I print in brackets :frowning:

Apparently Guido hates brackets :smiley:

Now I think Python3 is messed up instead of an improvement:

by the way, the correct syntax is from __future__ import print_function

Yes use

from __future__ import print_function, absolute_import, division

to improve your compatibility with modern python (python 3) whilst using legacy python (2.7, e.g. RhinoPython / GHPython)

1 Like