I wanted to call class member functions to initialize the class members completely in init. items_left and rat_initialize are the member functions I am using to initialize all the members of the class instance correctly. Is it alright to do so?
class Maze:
""" A 2D maze. """
# Write your Maze methods here.
def __init__(self,maze,rat_1,rat_2):
self.maze = maze
self.rat_1 = rat_1
self.rat_2 = rat_2
self.num_sprouts_left = 0
self.items_left(maze)
self.rat_initialize(maze,rat_1,rat_2)
Yes you can do it. When __init__
is called, the object is already instantiated by this point all the methods are available.
Actual object instantitation takes place in __new__
and __init__
is only called after it. You have accesss to other functions from inside __init__
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With