[Tutor] Class methods
Alexandre Conrad
alexandre.conrad at gmail.com
Thu Jun 23 00:48:42 CEST 2011
David,
2011/6/22 David Merrick <merrickdav at gmail.com>:
> # listen to your critter
> elif choice == "1":
> for critter in farmlet:
> farmlet.talk()
You want to call .talk() on your "critter" instance which has the
.talk() method, not on farmlet (which is a list as the error message
states)
> Traceback (most recent call last):
> File "I:/Python/programs/critter_farm4.py", line 117, in <module>
> main()
> File "I:/Python/programs/critter_farm4.py", line 103, in main
> farmlet.talk()
> AttributeError: 'list' object has no attribute 'talk'
You will probably have a problem when calling talk() because it
references to the "farmlet" variable which doesn't exist in the scope
of your .talk() method.
HTH,
--
Alex | twitter.com/alexconrad
More information about the Tutor
mailing list