# Class restaurant
class Restaurant:
""""This class describes a restaurant"""
def __init__(self, restaurant_name, cuisine_type):
""""Initialize name and age attributes"""
self.restaurant_name = restaurant_name
self.cuisine_type = cuisine_type
def describe_restaurant(self):
""""Method to describe the restaurant"""
print("Welcome to " + self.restaurant_name.title() + ", enjoy its " + self.cuisine_type + " cuisine.")
def open_restaurant(self):
""""Message to inform the customers that the restaurant is open"""
print(self.restaurant_name.title() + " is open. Please come in and enjoy your dinner.")
# creating an instance of the restaurant
restaurant = Restaurant('yaff', 'haute')
restaurant.describe_restaurant()
restaurant.open_restaurant()
I’m also having troubles importing a method from a class out of another module.
I have this module users.py, and I want to import one of the methods show_privileges from the Admin class into module privileges.py(there are two classes in users.py)
Unfortunately, pycharm states: ‘Cannot find reference show_privileges in users.py’
For some reason I can only add one picture in my comment.
Here’s the code that contains the show_privileges method.
class Admin(User):
"""
This class is based on the class User
"""
def __init__(self, first_name, last_name, age, gender):
super().__init__(first_name, last_name, age, gender)
self.privileges = ["it can add a post", "it can delete a post", "it can ban a user"]
def show_privileges(self):
print("An Admin has the following privileges:")
for privilege in self.privileges:
print("- " + privilege.capitalize())
admin = Admin('jeffrey', 'jongkees', 37, 'm')
admin.show_privileges()