Skip to Content
Head First Python, 개정판 : 스스로 질문하며 답을 찾는 파이썬 학습서(Python 3)
book

Head First Python, 개정판 : 스스로 질문하며 답을 찾는 파이썬 학습서(Python 3)

by 우정은, 폴 배리
December 2017
Beginner
624 pages
15h 38m
Korean
Hanbit Media, Inc.
Content preview from Head First Python, 개정판 : 스스로 질문하며 답을 찾는 파이썬 학습서(Python 3)
346 Chapter 7
클래스의 시대
안타까운 소식이 그렇게 나쁜 것은 아니에요
이전 페이지에서 좋은 소식은 프로그래머가 필요한 곳에
with
문을 사용할 수 있도록 파이썬에서
컨텍스트 관리 프로토콜을 제공한다는 사실이라고 설명했습니다.
with
문이 데이터베이스와
소통할 수 있도록
UseDatabase
라는 컨텍스트 관리자를 만들려면 컨텍스트 관리 프로토콜을
사용하는 방법을 이해해야 합니다.
로깅 데이터를 데이터베이스에 저장할 때 사용했던 설정과 마무리 코드는 큰 의미가 없는
표준
코드
입니다. 다음 예제처럼 설정과 마무리 코드를
with
문과 연결되도록 바꿀 수 있습니다.
안타까운 소식은 컨텍스트 관리자를 만들어 프로토콜과 연결하려면 파이썬 클래스를 만들어야
하는데 그리 간단하지 않다는 사실이죠.
지금까지 이 책에서는 클래스를 만들지 않고도 많은 유용한 코드를 구현했습니다. 특히 어떤
언어에서는 클래스를 만들지 않으면 아무것도 할 수 없다는 점을 감안할 때 상당히 훌륭하죠(자바!
보고 있나?).
더 이상 클래스를 피할 수 없는 막다른 골목에 다다랐습니다. 솔직히 파이썬에서는 클래스 만드는
게 그리 어렵지 않아요.
클래스는 유용한 기능을 제공합니다. 이 장에서는 웹앱에 데이터베이스 코드를 추가하는 주제에
집중했고 클래스와 관련한 내용은 다음 장에서 ...
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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

NGINX 쿡북 : 112가지 레시피로 배우는 고성능 부하분산, 보안, 서버 배포와 관리

NGINX 쿡북 : 112가지 레시피로 배우는 고성능 부하분산, 보안, 서버 배포와 관리

노승현, 데릭 디용기
몽고DB 완벽 가이드(3판): 실전 예제로 배우는 NoSQL 데이터베이스 기초부터 활용까지

몽고DB 완벽 가이드(3판): 실전 예제로 배우는 NoSQL 데이터베이스 기초부터 활용까지

김인범, 크리스티나 초도로우, 섀넌 브래드쇼, 오언 브라질

Publisher Resources

ISBN: 9791162240281