[Tutor] the class struggle

alan.gauld@bt.com alan.gauld@bt.com
Fri, 30 Nov 2001 13:32:41 -0000


> import random
> 
> class myObject(name):

This says you are defining a class that inherits from 
something called name, you probably don't mean that.

>   def __init__(self, name):

This says you have a constructor taking a parameter called 
name, this is starting to get confusing - to me if not to 
Python!

>     variable = name
>     anotherOne = anotherValue

anotherValue is presumably a global variable defined elsewhere?

>     if name in someList:

As is someList?
It might be better to pass these in as parameters to init() too.
Now which name are we referring to here? Is it the parent 
class or the parameter to the method?

I'm not sure how Python sees that but it might contribute. 
Its certainly confusing me!

BTW Without using self all of these values get thrown 
away when you finish __init__()... unless they are all 
globals!?

Alan g.

PS If someone else has already answered my apologies I'm 
catching up on the digested list during a very boring 
teleconference!!!