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
流畅的Python(第2版)
by
Luciano Ramalho
April 2023
Intermediate to advanced
769 pages
25h 16m
Chinese
Posts & Telecom Press
Content preview from
流畅的Python(第2版)
192
第
8
章
函数中的类型提示
还应该强调的是,
Python
仍是一门动态类型语言
,
作者并不意图强制使用类型
提示
,
这只是一种约定
。
——
Guido van Rossum
、
Jukka Lehtosalo
和
Ł
ukasz Langa
“
PEP
484
—
Type Hints
”
1
自
2001
年发布的
Python 2.2
统一类型和类之后,类型提示是
Python
历史发展过程中最大
的变化。但是,不是所有
Python
用户都能从类型提示中受益
。因此,必须把这作为一种可
选的功能。
“
PEP
484
—
Type Hints
”为函数参数、返回值和变量的显式类型声明规定了句法和语义,目
标是协助开发者工具通过静态分析(例如,不通过测试真正运行代码)发现
Python
基准代
码中的
bug
。
类型提示的主要受益者是使用
IDE
(
Integrated
Development
Environment
,集成开发环境)
和
CI
(
Continuous
Integration
,持续集成)的专业软件工程师。这类人群看重的是类型提
示的成本效益分析,不是所有
Python
用户都关注这一点。
Python
的用户群体分布广泛
,包括科学家、交易员、记者、艺术家、创客、分析师和许多
学科的学生等。对他们中的大多数人来说,学习类型提示的成本可能较高,除非以前用过
具有静态类型、子类型和泛型的语言。考虑到他们使用
Python
的方式
,以及基准代码和团
队(通常是“一人团队”)的规模较小,这些用户的收益较低。
Python
默认的动态类型更
简单,也更具表现力,特别适合在数据科学 ...
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
Python高级编程(第2版)
Posts & Telecom Press, Michał Jaworski, Tarek Ziadé
Python语言及其应用(第2版)
Bill Lubanovic
Kafka权威指南(第2版)
Gwen Shapira, Todd Palino, Rajini Sivaram, Krit Petty
Python贝叶斯分析(第2版)
Posts & Telecom Press, Osvaldo Martin
Publisher Resources
ISBN: 9787115612366