 <p><a href="http://www.tutorialspoint.com/python/python_strings.htm" rel="nofollow">Strings in python</a> are declared using double or single quotes, therefore the variable <strong>data</strong> contains a string. You can check the type of a variable directly in python:</p> <pre><code>data = "000000000000000117c80378b8da0e33559b5997f2ad55e2f7d18ec1975b9717" type(data) </code></pre> <p>which outputs</p> <pre><code>str </code></pre> <p>meaning that the variable is a string. When you call the function decode('hex') on a string you obtain another string:</p> <pre><code>data.decode('hex') '\x00\x00\x00\x00\x00\x00\x00\x01\x17\xc8\x03x\xb8\xda\x0e3U\x9bY\x97\xf2\xadU\xe2\xf7\xd1\x8e\xc1\x97[\x97\x17' </code></pre> <p>Every character in your original string is interpreted as an hexadecimal number, and every pairs of hexadecimal numbers - e.s. "17" - is converted into an hexadecimal character using the escape sequence \x - becoming "\x17".</p> <p>When you write "\x41" you are basically telling python to interpret 41 as a single ASCII character whose hexadecimal representation is 41.</p> <p>The <a href="http://www.asciitable.com/" rel="nofollow">ASCII table</a> contains the hexadecimal, decimal and octal values associated to the ascii characters.</p> <p>If you try for example</p> <pre><code>"48454C4C4F".decode('hex') </code></pre> <p>you obtain the string "HELLO"</p> <p>Lastly when you use [::-1] on a string you reverse it:</p> <pre><code>"48454C4C4F".decode('hex')[::-1] </code></pre> <p>produces the string "OLLEH"</p> <p>You can find more about the escape characters reading the <a href="https://docs.python.org/2.0/ref/strings.html" rel="nofollow">python documentation</a>.</p>