[Tutor] Beginner question on classes
Alan Gauld
alan.gauld at btinternet.com
Wed Oct 23 11:26:53 CEST 2013
On 23/10/13 08:25, Corinne Landers wrote:
> Hi guys,
>
> I need a bit of help.
> I'm writing a class, and in the main function I'm trying to say if this
> method gets called, do this.
What you are actually doing is "if the method returns
a truth-like value do this." Not quite the same thing,
but much easier!
> I'm trying things like:
>
> program = AnimalClass(x,y,z)
> for i in range(x):
> for j in range(y):
> for k in range(z):
> animal = program.animal()
> if animal:
> if isinstance(animal,moose):
> print("There is a moose here")
The block below for k... needs more indentation and
The final print needs yet another level of indentation...
> It's clearly not correct because it's giving me all sorts of grief,
Could you be more specific? What kind of grief?
Error messages? Then send the full message here.
Your computer crashes?
It doesn't print a message you expected?
While you are at it which Python version and OS are you using?
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list