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판)
289
7
장
일급 객체로서의 함수
7
.
2
함수를 객체처럼 다루기
[
예제
7
-
1
]의 콘솔 세션은 파이썬 함수가 객체임을 보여 준다. 여기서 함수를 생성하고, 호출
하고,
__doc__
속성을 읽고, 함수 객체 자체가
function
클래스의 객체인지 확인한다.
예제
7-1
함수를 생성해 테스트하고, 함수의
__
doc
__
을 읽어서 자료형 확인하기
>>>
def factorial(n):
❶
... “””returns n!”””
... return 1 if n < 2 else n * factorial(n - 1)
...
>>>
factorial(42)
1405006117752879898543142606244511569936384000000000
>>>
factorial.__doc__
❷
‘returns n!’
>>>
type(factorial)
❸
<class ‘function’>
❶ 지금 콘솔 세션에 있으므로, 함수를 ‘런타임’에 만들고 있는 것이다.
❷
__
doc
__
은 함수 객체의 여러 속성 중 하나다.
❸
factorial
은
function
클래스의 인스턴스이다.
__doc__
속성은 객체의 도움말 텍스트를 생성하는 데 사용된다. 파이썬 대화형 콘솔에서
help(factorial
)
문을 실행하면 [그림
7
-
1
]과 같은 메시지를 출력한다.
그림
7-1
factorial
()
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