mfletch at tpresence.com
Wed Oct 18 03:24:20 CEST 2000
Python tries not to do "magic" stuff when you add variables (since people
often expect magic to do different things depending on intention, rather
than anything in the code). Use string formatting (my recommended practice,
not that my recommending anything means much), which is a very powerful
mechanism in Python inherited from C:
'<%s>'% (intName )
or, if that's too weird for you, use the built-in function str to convert to
a string representation before adding:
'<' + str( intName) + '>'
(see also: hex, oct, int, float, long, string.atoi, string.atof,
From: Mark Cunningham [mailto:mcunni01 at uoguelph.ca]
Sent: Tuesday, October 17, 2000 9:18 PM
To: python-list at python.org
Subject: String adding.
i know doing:
strName = 'wow'
'<' + strName + '>'
will give you <wow>
but what about:
intName = 3
print '<' + intName + '>'
this gives me some illegal argument type for built-in operation..
how would i make it give me <3>????
More information about the Python-list