List print function

Hi,

Today I am looking at print functions of lists and below I cannot get the format

print(*header, sep = " ")

to work, I get the following error message back

File “C:\V6 Scripts - Plugin\Python\GeoSpatial Points To 3DIM.py”, line 40
print(header, sep = " ")
^
SyntaxError: unexpected token '

The format is the same as explained on many websites yet gives me an error so it must be something I have done or not done as may be the case.

If I use a loop I print exactly what I need but my stubborn nature would like to know why the other method gives an error.

Roger

header=
header.append(“VER,2.4,GLM 3-Dim Observer,”)
header.append(“MTH,none,0,”)
header.append(“DEV,”)
header.append(“MAT,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,”)
header.append(“REM,ID,SortOrder,Name,Memo,Memo2,Meas.x,Meas.y,Meas.z,RealMeas.x,RealMeas.y,RealMeas.z,Ref.x,Ref.y,Ref.z,Offset.x,Offset.y,Offset.z,X_Check,Y_Check,Z_Check,MTol.x,MTol.y,MTol.z,PTol.x,PTol.y,PTol.z,Visible,Marked,PointType,Code,”)
header.append(“MPT,1,1,$IPos1,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,NaN,NaN,NaN,0.00000,0.00000,0.00000,Y,Y,Y,NaN,NaN,NaN,NaN,NaN,NaN,N,N,InstrumentPositionPoint,”)
print(*header, sep = " ")
for item in (header):
print(item)

Hello,

This is a Python 2 vs Python 3 problem. You could try print " ".join(header) instead

Hi Graham,

Thank you for pointing that out to me I will have to be far more particular when looking up information and stipulate Iron Python or Python 2.7.

Yes most code will work with both but I think you found two incompatibilities there in a single line: the print function and iterable unpacking with the star. :smiley: