[Tutor] Please explain TypeError

D. Guandalino guandalino at gmail.com
Mon Aug 22 00:27:59 CEST 2011

On 22 August 2011 00:17, Dave Angel <d at davea.name> wrote:

> On 08/21/2011 05:35 PM, D. Guandalino wrote:
>> Python documentation says:
>>  exception TypeError
>>> Raised when an operation or function is applied to an object of
>>> inappropriate type. The associated value is a string giving details
>>> about the type mismatch.

>  You didn't supply a parameter in the __init__() to receive the value of 1.
>  The self argument is automatically supplied by Python for all ordinary
> method calls including initial object construction.  So when you say   C(1)
>  you're actually going to get 2 arguments in the __init__() call.
> Add another parm to the definition:
>          def __init__(self, startvalue):
>                     pass

Thanks and apologies for not being clear.

I missed to say that I'm more interested in understanding which error I did
with types (given that a TypeError is raised) than in fixing the code.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110822/fa964f4c/attachment.html>

More information about the Tutor mailing list