The code you show works fine for me. The error you're seeing is almost certainly the result of inadvertently using 'str' as a variable name earlier in the IDLE session: Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29) [GCC 4.2.1 (Apple Inc. build 5646)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> str = '4bf3e914' >>> hell = str(123) Traceback (most recent call last): File "", line 1, in TypeError: 'str' object is not callable >>> help(str) no Python documentation found for '4bf3e914'