Skip to Content
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
Explore Skills
Cloud Computing
Microsoft Azure
Amazon Web Services (AWS)
Google Cloud
Cloud Migration
Cloud Deployment
Cloud Platforms
Data Engineering
Data Warehouse
SQL
Apache Spark
Microsoft SQL Server
MySQL
Kafka
Data Lake
Streaming & Messaging
NoSQL Databases
Relational Databases
Data Science
Pandas
R
MATLAB
SAS
D3
Power BI
Tableau
Statistics
Exploratory Data Analysis
Data Visualization
AI & ML
Generative AI
Machine Learning
Artificial Intelligence (AI)
Deep Learning
Reinforcement Learning
Natural Language Processing
TensorFlow
Scikit-Learn
Hyperparameter Tuning
MLOps
Programming Languages
Java
JavaScript
Spring
Python
Go
C#
C++
C
Swift
Rust
Functional Programming
Software Architecture
Object-Oriented
Distributed Systems
Domain-Driven Design
Architectural Patterns
IT/Ops
Kubernetes
Docker
GitHub
Terraform
Continuous Delivery
Continuous Integration
Database Administration
Computer Networking
Operating Systems
IT Certifications
Security
Network Security
Application Security
Incident Response
Zero Trust Model
Disaster Recovery
Penetration Testing / Ethical Hacking
Governance
Malware
Security Architecture
Security Engineering
Security Certifications
Design
Web Design
Graphic Design
Interaction Design
Film & Video
User Experience (UX)
Design Process
Design Tools
Business
Agile
Project Management
Product Management
Marketing
Human Resources
Finance
Team Management
Business Strategy
Digital Transformation
Organizational Leadership
Soft Skills
Professional Communication
Emotional Intelligence
Presentation Skills
Innovation
Critical Thinking
Public Speaking
Collaboration
Personal Productivity
Confidence / Motivation
Features
All features
Verifiable skills
AI Academy
Courses
Certifications
Interactive learning
Live events
Superstreams
Answers
Insights reporting
Radar Blog
Buy Courses
Plans
Sign In
Try Now
O'Reilly Platform
book
전문가를 위한 파이썬(2판)
by
루시아누 하말류
,
강권학
November 2024
Beginner to intermediate
1064 pages
25h 21m
Korean
Hanbit Media, Inc.
Content preview from
전문가를 위한 파이썬(2판)
635
15
장
자료형 힌트 조금 더 알아보기
❶
T
_
co
를 공변적으로 선언한다.
❷ 이렇게 함으로써
RandomPicker
를 공변적 형식형 매개변수가 있는 제네릭형으로 만든다.
T
_
co
를 반환형으로 사용한다.
제네릭
RandomPicker
프로토콜은 단 하나 있는 형식 매개변수가 반환형으로 사용되므로 공변
적이다.
이것으로 이 장을 마치고자 한다.
15
.
9
요약
이 장은
@overload
를 사용한 간단한 예제로 시작해 더욱 복잡한 예제들을 만들어가며 자세히
살펴보았다. 내장 함수
max(
)
를 제대로 어노테이트하려면 오버로드된 시그너처가 필요했다.
typing.TypedDict
특별 구조체가 그 뒤에 이어졌다.
typing.NamedTuple
을 다룬
5
장
이 아니라 여기에서 설명하기로 한 이유는
TypedDict
가 클래스 빌더가 아니기 때문이다.
TypedDict
는 특정한 일련의 문자열 키와 각 키에 대한 특정한 자료형을 가진
dict
형을 요구
하는 변수나 인수에 자료형 힌트를 붙이는 방법이다.
TypedDict
는
JSON
데이터를 처리하는
경우처럼
dict
를 일종의 레코드로 사용할 때 도움이 된다. 이 절은 다소 길었다.
TypedDict
를
사용하는 게 안전하다는 잘못된 생각을 갖기 쉬운데, 본질적으로 동적인 매핑형으로부터 정적
으로 구조화된 레코드를 생성할 때 필수인 런타임 검사와 에러 처리하는 방법을 보여 주고자
했기 때문이다.
다음으로
typing.cast(
)
함수를 설명했는데, 이 함수는 자료형 검사기의 작동 방식을 조정
할
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판)
오현석, 미샤 고렐릭, 이안 오스발트
Publisher Resources
ISBN: 9791169211772