I'm trying to develop a simple script that will keep the scores of a cricket match.
In my script I want the __init__ method on one class to create an object of another class.
here's an example.
class Person: def __init__(self,name): self.name = name class clubMember: def __init__(self,name): New_clubmember = Person(name)
Now, I believe this code is correct because it doesn't raise any error at runtime. However, I can't write any code that will you the object "New_clubmember.".
Any other function which is written to use New_clubmember says that it has not been defined.
My question is: How do I use the New_clubmember object --which was created by the __init__ statement in club_Member -- in a function which is outside the clubMember class?
Edited 7 Years Ago by vegaseat: code tags corrected