I am trying to understand 'self' in python on a deeper level because while I use it, I find myself not understanding it in full.
Consider the code below
class FoodItems:
def __init__(self, other arguments):
some code
def main():
some code
item1 = FoodItems
item1.main()
For the method [ def main() ] I am not passing the parameter 'Self' in it and the code works when I call it. My understanding of 'Self' is that it has to be passed every time a method is created under the class. If I pass 'Self', and then call the method, I get the error ( missing 1 required positional argument: 'self')
Can some one explain this to me?
Now, the second part of the question, when it comes to creating instances,I cant tell the difference between calling an instance with or without parentheses such as ( item1 = FoodItems Vs. item1=FoodItems() )
Note: When I use parantheses I get the error, missing 8 required positional arguments that have been initialized in the constructor.
Any help would be greatly appreciated, thanks in advance!