Python end=


a, b = 0, 1
while b < 1000:
…print(b, end=’,’)
…a, b = b, a+b

does not work in ghpython

at the end of the tutorial

Rhino is using IronPython 2.7x, not Python 3.

1 Like

I haven’t tried, but maybe you could try this:

Btw, in general, it would help if you attached the definition you are working on.

1 Like

try this:

from __future__ import print_function
print(b, end=’,’)

1 Like

Hey! From the future? What do you mean with future?

__future__ contains Python 3 functions that have been back-ported to v2

Please note that for some reason, the underscores were missing in my earlier post. I didn’t tag it as pre-formatted text.
Using __future__ will make it much easier to port to v3

1 Like

2 posts were split to a new topic: Printing a tuple with a single item

Sorry, I do not understand how it works.
Do I have to install ‘future?’ What is port to v3?
Or did I missed it in the documentation?
I am now studying paragraph 4.6 of the pyhton tutorial.

python -end- (2.2 KB)

The error message on your component tells you what to do - __future__ imports are special and must be placed at the very top of the script.
Just reorder the first 3 lines to :

from __future__ import print_function
import math
import rhinoscriptsyntax as rs

and the rest works :slight_smile:

PS. Rhino/Grasshopper only runs on IronPython 2.7.x, so you should be reading the Python 2 version of the tutorials, not Python 3.

1 Like

Thank you :slight_smile: