Open
Conversation
rover0811
reviewed
Oct 17, 2025
Member
rover0811
left a comment
There was a problem hiding this comment.
# 문제 3: magic_method.py 확장
class Fruit(object):
def __init__(self, name, price):
self._name = name
self._price = price
def __add__(self, target):
return self._price + target._price
apple = Fruit("사과", 100)
banana = Fruit("바나나", 100)
fruits = {apple, banana} # 이게 작동할까요?
print(len(fruits)) # 1일까요? 2일까요?|
|
||
| <!-- 가장 중요하다고 생각하는 개념이나 배운 점을 작성해주세요 --> | ||
|
|
||
| #### 딕셔너리로 제너레이터 컴프리헨션 불가능하다. |
|
|
||
| <!-- 이번 주차에서 학습한 내용을 3-5줄로 요약해주세요 --> | ||
|
|
||
| - 제너레이터는 지연 평가 방식이 가능하기 때문에 객체에 엄청나게 많은 데이터를 넣어 생성해야 할 때에는 컴프리헨션보다 효율성 측면에서 매우 뛰어나다. |
|
|
||
| #### 언패킹은 함수에서 사용할때 주의해야함. | ||
|
|
||
| - 인자를 해체하는 개념이기 때문에 해체된 인자의 개수가 함수의 인자 개수와 다르다 에러가 발생함 |
Member
There was a problem hiding this comment.
함수 정의에서 *args, **kwargs와 호출 시 *list, **dict의 차이는 뭘까요?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
학습 내용 요약
핵심 개념
딕셔너리로 제너레이터 컴프리헨션 불가능하다.
언패킹은 함수에서 사용할때 주의해야함.
제너레이터는 컴프리헨션보다 메모리 효울성이 좋다.
함수에 데코레이터 편하게 적용하려면 @를 사용하면된다.
실습 예제
참고 자료
컴프리헨션
언패킹
제너레이터
매직메소드
데코레이터
체크리스트