On Sat, 18 Apr 2009 11:45:09 -0700 (PDT), grocery_stocker wrote: > I'm just really not seeing how something like x63 and/or x61 gets > converted by 'print' to the corresponding chars in the following > output... > > [cdal...@localhost oakland]$ python > Python 2.4.3 (#1, Oct 1 2006, 18:00:19) > [GCC 4.1.1 20060928 (Red Hat 4.1.1-28)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>> print '\x63had' > chad >>>> print '\x63h\x61d' > chad >>>> print "\x63had" > chad >>>> print "\x63h\x61d" > chad >>>> > > Does print just do this magically?
I'm not sure what magic you see in there, but does the following help? >>> a = "\x63had" >>> len(a) 4 >>> b = "\x63h\x61d" >>> len(b) 4 Personally, when I'm puzzled by something involving a string with backslashes, I use len to help figure out what's really in the string and what's inserted on the way to my screen. -- To email me, substitute nowhere->spamcop, invalid->net. -- http://mail.python.org/mailman/listinfo/python-list