# Blender console formatted printing: Is there a maximum length?

With the default cube mesh and Blender 2.77, if I run this code in console:

for f in bpy.data.meshes['Cube'].polygons:
for v in f.vertices:
print("%f %f %f" % bpy.data.meshes['Cube'].vertices[v].co[:])
print("%f %f %f" % f.normal[:])
print("\n")


I get the following output (truncated for brevity):

-1.000000 -1.000000 1.000000
-1.000000 0.000000 0.000000
-1.000000 1.000000 1.000000
-1.000000 0.000000 0.000000
-1.000000 1.000000 -1.000000
-1.000000 0.000000 0.000000
-1.000000 -1.000000 -1.000000
-1.000000 0.000000 0.000000

-1.000000 1.000000 1.000000
0.000000 1.000000 -0.000000
...


However, with this:

for f in bpy.data.meshes['Cube'].polygons:
for v in f.vertices:
print("%f %f %f %f %f %f\n" % bpy.data.meshes['Cube'].vertices[v].co[:], f.normal[:])
print("\n")


or even this:

for f in bpy.data.meshes['Cube'].polygons:
for v in f.vertices:
print("%f %f %f %f %f %f" % bpy.data.meshes['Cube'].vertices[v].co[0], py.data.meshes['Cube'].vertices[v].co[1], py.data.meshes['Cube'].vertices[v].co[2], f.normal[0], f.normal[1], f.normal[2])
print("\n")


I get the error:

Traceback (most recent call last):
File "<blender_console>", line 3, in <module>
TypeError: not enough arguments for format string


Why can I print 3 floats easily but printing 6 floats doesn't work? Is Python's formatted printing different that C's (in this respect)? Or is it something Blender specific? Is there a maximum limit on how many 'arguments' the format string can take?

• print( "%f, %f" % (1, 2) ) , more information here stackoverflow.com/questions/15286401/… – lemon Sep 4 '16 at 6:30
• @lemon Putting all the floats in a list works for program 3, but it is tedious to type. Is there any way to make it work for program 2 (with two separate lists)? – strNOcat Sep 4 '16 at 6:35
• Have a look here stackoverflow.com/questions/455612/… and combine format function as you need – lemon Sep 4 '16 at 6:51
• You can also change the end character of print from its default "\n" (carriage return) with print(str, end=",") for example. Something like cube = bpy.data.meshes.get("Cube") and for v in cube.vertices: would make the code a whole lot more readable... and also I vote to close this q as it is not really about blender python or the console, rather a syntax error. – batFINGER Sep 4 '16 at 7:59
• I'm voting to close this question as off-topic because it is primarily about python. – batFINGER Sep 4 '16 at 8:01

for f in bpy.data.meshes['Cube'].polygons: