n00b formatting

Tim Chase python.list at tim.thechases.com
Thu Feb 24 18:05:09 EST 2011


On 02/24/2011 04:46 PM, Verde Denim wrote:
> On Thu, Feb 24, 2011 at 12:49 PM, MRAB<python at mrabarnett.plus.com>  wrote:
>
>> On 24/02/2011 16:41, Verde Denim wrote:
>>> x = '0D'
>>> y = '0x' + x
>>> print "%d" % int(y,0)
>>> TypeError: 'int' object is not callable
>>>
>>> what am i not seeing here??
>>
>>   I can only assume that at some point you assigned an int to 'int'.
>
>      def __dump(self):
>          x = int = 0
>          z = int = -1

As MRAB writes, you're assigning int values to "int" here, 
overriding the int() function.  These are semi-equivalent to

   x = 0
   int = 0
   z = -1
   int = 0

so when you get to

>  print "%d" % (int(self.__asn1_called_ident_length,0))

"int" no longer refers to the built-in, but rather a name for 
"-1", thus the error.

-tkc






More information about the Python-list mailing list