I just started learning classes in Python and faced such a problem (or not) that when outputting the result, the first line goes:
<__main__.Restaurant object at 0x0042DE90> I was interested in this, but I did not find the answer on the Internet, so I hope that the experts will help. Here is all the code to clarify the issue:
class Restaurant: def __init__(self, restaurant_name, cuisine_type): self.restaurant_name = restaurant_name self.cuisine_type = cuisine_type def describe_restaurant(self): print(self.restaurant_name) print(self.cuisine_type) def open_restaurant(self): print(self.restaurant_name+' is open!') my_rest = Restaurant('Clot monet', 'classical') print(my_rest) my_rest.describe_restaurant() my_rest.open_restaurant() OUTPUT:
<__main__.Restaurant object at 0x0042DE90> Clot monet classical Clot monet is open! Process finished with exit code 0
__main__module, and theRestaurantclass is created inside the__main__- andreymal module 6:29 pm__str__method in your class, example: github.com/gil9red/SimplePyScripts/blob/… , github.com/gil9red/SimplePyScripts/blob/… - gil9red