Skip to Content
전문가를 위한 파이썬(2판)
book

전문가를 위한 파이썬(2판)

by 루시아누 하말류, 강권학
November 2024
Beginner to intermediate
1064 pages
25h 21m
Korean
Hanbit Media, Inc.
Content preview from 전문가를 위한 파이썬(2판)
446
3
클래스와 프로토콜
예제
11-10
Vector2d
대상에 대한 위치 패턴(파이썬
3
.
10
이상 버전 필요)
def positional_pattern_demo(v: Vector2d) -> None:
match v:
case Vector2d(0, 0):
print(f’{v!r} is null’)
case Vector2d(0):
print(f’{v!r} is vertical’)
case Vector2d(_, 0):
print(f’{v!r} is horizontal’)
case Vector2d(x, y) if x==y:
print(f’{v!r} is diagonal’)
case _:
print(f’{v!r} is awesome’)
__match_args__
클래스 속성에 공개 속성이 모두 들어갈 필요는 없다. 특히 인스턴스 속성에
할당될 필수 인수와 선택 인수를
__init__( )
가 받을 때, 필수 인수는
__match_args__
에 지
정하는 편이 좋지만 선택 인수까지 모두 지정할 필요는 없다.
이제 잠시 숨을 고르면서 지금까지
Vector2d
에 구현한 코드를 돌아보자.
11
.
9
Vector2d
버전 #
3
: 전체 코드
지금까지
Vector2d
클래스를 개선하면서 추가된 코드 부분만 보았다. [예제
11
-
11
]은 지금까
지 수정한 내용과 클래스를 개발하면서 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

전문가를 위한 리액트

전문가를 위한 리액트

테자스 쿠마르
고성능 파이썬(2판)

고성능 파이썬(2판)

오현석, 미샤 고렐릭, 이안 오스발트

Publisher Resources

ISBN: 9791169211772