Keep getting this in PyDev "TypeError: quiz() takes exactly 1 argument (0 given)"

Dave Angel d at davea.name
Fri Aug 10 16:50:26 EDT 2012


On 08/10/2012 04:28 PM, Chuck wrote:
> Thanks for the help guys!  I finally got it working.  Shouldn't I technically call quiz() through the constructor, though?  Otherwise, the constructor is pointless.

> 
> Thanks again!
> 

What language did you use before trying Python?  Was it java, by any
chance, where everything has to be in a class?  If you're going to do
everything from the "constructor", then why on earth would you make it a
class?

(Incidentally, __init__() is the initializer, not the constructor, which
is called __new__() )

If you want to make a proper class out of it, you'd move the
initalization code into the __init__(), call, the stuff that only needs
to be called once per instance.  On the other hand, you have a class
attribute 'elements, which gets initialized outside of any mmthod.  And
everything else is just locals.

>  I just put in pass for now.  (Also, I always thought that
> if __name__ == '__main__': went IN the class.  Why wouldn't
> it be apart of the class?  )

Seems like you're arguing both sides.  Anyway, the if __name__ stuff
does not belong inside any class.  This is Python.

-- 

DaveA



More information about the Python-list mailing list