tag:blogger.com,1999:blog-8722048993094113071.post7485910370440148182..comments2023-09-11T06:34:38.721-07:00Comments on The world is amazing: Python: Convert integer into stringUnknownnoreply@blogger.comBlogger2125tag:blogger.com,1999:blog-8722048993094113071.post-59354152014273165762009-10-23T11:09:45.360-07:002009-10-23T11:09:45.360-07:00Another option is to use backticks/accents located...Another option is to use backticks/accents located on the ~ (tilde) key. This has the effect of translating python objects into a string. Just put them around the python object (in this case `x`) when concatenating with a string. A drawback is that you lose control over the format of how the object is displayed.<br /><br />Example 1:<br />>>> x = 3<br />>>> 'object: ' + `x`<br />"object: 3"<br /><br />Example 2:<br />>>> x = [3,4,'asdf']<br />>>> 'object: ' + `x`<br />"object: [3, 4, 'asdf']"<br /><br />Example 3:<br />>>> def x():<br />... print 'nothing'<br />...<br />>>> x()<br />nothing<br />>>> x<br /><function y at 0x009F9F30><br />>>> 'object: ' + `x`<br />'object: <function x at 0x009F9F30>'happystainhttps://www.blogger.com/profile/00674543837258030496noreply@blogger.comtag:blogger.com,1999:blog-8722048993094113071.post-54134114923804689222009-10-19T19:46:15.060-07:002009-10-19T19:46:15.060-07:00Thank you for having this readily available. You w...Thank you for having this readily available. You were right, that is not an easy function to come across looking through the python documentation.<br /><br />The Calm Crisis<br />http://calmcrisis.wordpress.com/TJ Lockehttps://www.blogger.com/profile/12497225314387863275noreply@blogger.com