TypeError: int argument required

mblume mblume at socha.net
Fri Jun 12 14:36:47 CEST 2009


Am Thu, 11 Jun 2009 20:56:24 -0700 schrieb lucius:

> I am trying to
> print some values to a file (using c's printf like method). TypeError:
> int argument required
> # this works, i see value on screen
>  print  w, h, absX, absY
> 
Are you sure that w or h are not returned as strings?
Hint: try this in an interpreter:
w="100"
print "%d" % (w)

> 
> # this fails, I get "TypeError: int argument required"
> 	   print >> fo, "<rect x=\"%f\" y=\"%f\" width=\"%d\" height=\"%d\"
> style=\"fill:blue;stroke:pink;stroke-width:5;fill-opacity:0.1;stroke-
> opacity:0.9\"/> " % (absX, absY, w, h)
> 

You could simplify such as an expression by writing:
print 'x="%f"' % (x)

HTH
Martin



More information about the Python-list mailing list