Question about some Code-Signs

I’m looking at some Code examples.

In the API documentation I can’t find anything about the following signs in a Codeline:


for poly in me.polygons:
    print("Polygon index: %d, length: %d" % (poly.index, poly.loop_total))

What does that “%d” do ?

And


for f in me.faces:         
    f.material_index = f.index % 3

What kind of Operation (if it is any) is this “%” ?

Kind regards
Alain

those are standard-python questions, not actually about Blender.

% in strings are used for string formatting:

“Value: %d” % 12

%d is for signed integers

https://docs.python.org/3.4/library/stdtypes.html#printf-style-string-formatting

On numbers, % is the mathematical operation “modulo”:
https://docs.python.org/3.4/library/functions.html#divmod

Thanks for the link to the Python Documentation.
Sorry for asking such basics, I think I will find there the answer for some other basic questions as well.

Kind regards
Alain

You’re welcome. The python docs are good, but for learning there are probably better places which are less overwhelming and didactically edited. There are several threads with links about such learning resources around here.