-
Notifications
You must be signed in to change notification settings - Fork 2
Session1/erun1012 #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
b514e8c to
4b54f5f
Compare
rover0811
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
결과를 맞춰보세요!
def uppercase(func):
def wrapper():
result = func()
return result.upper()
return wrapper
def add_exclamation(func):
def wrapper():
result = func()
return result + "!"
return wrapper
@uppercase
@add_exclamation
def greet():
return "hello"
print(greet()) # 결과는? "HELLO!" vs "hello!".upper()?
| numbers = [1, 2, 3, 4, 5] | ||
| first, *middle, last = numbers | ||
| print(first, middle, last) | ||
| # 1 {2,3,4}, 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
실제로 이렇게 나오나요?
| date2 = [] | ||
| for i in range(1,6): | ||
| for j in range(1,4): | ||
| data2.append((i,j)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오타가 있어서 실행이 안될 것 같아요
|
|
||
| ```python | ||
| lst=[x*2 for x in range(5)] | ||
| gen=(x*2 for x in range(5)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
list(gen) # [0, 2, 4, 6, 8]
list(gen) # ??? -> 여기서 뭐가 나올까요?
| yield 1 | ||
| yield 2 | ||
| yield 3 | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def gen_with_return():
yield 1
yield 2
return "끝" # 이 값은 어떻게 접근할까요?
yield 3 # 이건 실행될까요?
| self.x, self.y = x, y | ||
|
|
||
| def __eq__(self, other): | ||
| return self.x == other.x and self.y == other.y |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__eq__를 구현하면 왜 __hash__도 필요할까?
set이나 dict의 키로 사용할 때 어떤 문제가 생길까요?
Python은 왜 자동으로 해시를 무효화할까요?
| return func(*args, **kwargs) #7 | ||
|
|
||
| return sentence #4 | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
functools.wraps에 대해 좀 더 찾아보면 좋을 것 같아요.
학습 내용 요약
__str__vs__repr__와 매직메서드의 역할핵심 개념
실습 예제
개념을 정리한 md 파일에 예제 코드를 참조함
참고 자료
https://tibetsandfox.tistory.com/25
https://tibetsandfox.tistory.com/28
https://tibetsandfox.tistory.com/39
https://tibetsandfox.tistory.com/42
https://tibetsandfox.tistory.com/10
체크리스트