Skip to content

Instantly share code, notes, and snippets.

@kizmo04
Created February 2, 2017 19:27
Show Gist options
  • Save kizmo04/1705edba9470411cde63c9ecfa4fcd12 to your computer and use it in GitHub Desktop.
Save kizmo04/1705edba9470411cde63c9ecfa4fcd12 to your computer and use it in GitHub Desktop.
class Recipes:
"""
재료를 활용해 조리법에 맞게 요리를 만들자
"""
description = '레시피를 활용해 음식을 만들자'
prepare = '손을 깨끗이 씼어요'
display = '원형 접시에 담을겁니다'
def __init__(self, ingredient, food):
self.__ingredient = ingredient
self.food = food
@property
def aaa(self):
return self.__ingredient
@aaa.setter
def ppp(self, a):
self.__ingredient = a
def with_pan(self):
"""
ingredient에 할당된 재료를 팬에 넣고 구우면
food에 할당된 음식이 완성된다는 문장을 리턴
:return: 스팸을 팬에 넣고 구우면 스팸구이 완성!
"""
return '{}을 팬에 넣고 구우면 {}완성!'.format(self.aaa, self.food)
egg = Recipes('계란', '계란후라이')
print(egg.with_pan())
egg.ppp = '달걀'
print(egg.with_pan())
print(type(egg.with_pan))
print(type(egg.ppp))
print(type(egg.aaa))
print(type(egg.food))
print(egg.ppp)
print(egg.aaa)
@kizmo04
Copy link
Author

kizmo04 commented Feb 2, 2017

@Property와 @.setter가 궁금해서 함수 이름을 바꿔봤는데요, 데코레이터를 붙였더니

  1. 인스턴스.함수명(egg.ppp, egg.aaa) 으로 속성처럼 접근해서 쓸 수 있고
  2. 데코레이터를 붙인 함수는 not callable이 됐습니다
  3. 함수의 타입을 출력해보니 str이라고 나오는데

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment