Hi,
I had this question posted earlier, but it wasn't very clear, and I had trouble with the answers. Since I edited it to make MUCH more sense it seems that people haven't been looking at it, perhaps because they see it already has 6 answers. So I'm re=-posting it here:
I'm still new to Python and Programming in general, so I need simple explanations! I don't even know what this dictionary thing you're talking about is!
I'm trying to create a game for my little sister. It is a Virtual Pet sort of thing and the Pet has toys to play with.
I created a class Toy
and want to create a function, getNewToy(name, data1, data2, data3, data4, data5)
.
I want this function to create a new instance of the class Toy
, and I want the function to be able to be called multiple times each time creating a new instance.
In my experience you create an instance with:
class Toy:
def __init__(self, name, data1, data2, data3, data4, data5):
pass
myToy = Toy(myToy, 1, 2, 3, 4, 5)
then to use methods from the class with:
myToy.method1()
Seeing as I want to have the ability to have multiple toys, each with a playWith()
method I want the instance to reflect the name of the Toy
each time one is called.
I want the instance to be different each time I call the method getNewToy(,...)
and the instance to reflect the name.
Remember I'm new to programming, so can you keep explanations simple.
Thank you very much, it's much easier to understand now!