On 31/10/2014 09:05, ast wrote:

"Seymore4Head" <Seymore4Head@Hotmail.invalid> a écrit dans le message de
news:51755at03r0bidjqh3qf0hhpvjr8756...@4ax.com...
class pet:
   def set_age(self,age):
       self.age=age
   def get_age(self):
       return self.age
pax=pet
pax.set_age(4)

Traceback (most recent call last):
 File "C:\Functions\test.py", line 18, in <module>
   pax.set_age(4)
TypeError: set_age() missing 1 required positional argument: 'age'

I am trying to pass 4 as the age.  Obviously I am doing it wrong.


Hi

I am a beginner too, but I find it strange that your
pet class has no __init__ method to construct
instances

__init__ initialises instances, __new__ constructs them

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to