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)
지금 여기예요
4
547
고급 반복
‘튜플 컴프리헨션’은 어디에?
파이썬은 튜플, 리스트, 집합, 딕셔너리 네 개의 내장 자료구조를 제공합니다. 그런데 튜플만
컴프리헨션이 없어요.
왜죠?
튜플 컴프리헨션
이라는 개념이 이치에 맞지 않기 때문입니다. 튜플은 바꿀 수 없는 자료구조, 즉
만든 다음에는 바꿀 수 없다는 사실을 기억하세요. 따라서 아래
IDLE
예제가 보여주는 것처럼
코드로 튜플의 값을 만들 수 없습니다.
새로운 빈 튜플을
만듭니다.
튜플에 동적으로
데이터 추가를
시도합니다.
튜플은 바꿀 수
없으므로 기존
튜플에 데이터를
추가할 수 없습니다.
한 번 만들었으면 바꿀 수 없다
는 것이 기본 개념이므로 이상하거나 놀라운 사실도 없습니다.
이 사실 하나만으로도 튜플 컴프리헨션이 왜 없는지 의문이 풀립니다. 다음
>>>
프롬프트
예제 코드를 보세요. 두 번째 루프는 첫 번째 루프와 조금 다릅니다. 첫 번째 루프에 사용한
리스트컴프의 대괄호를 두 번째 루프에서는 괄호로 바꿨어요.
리스트의 값을 세 배로 만들어 출력하는
for 루프와 리스트 컴프리헨션 조합이에요.
대괄호로 감싼 코드는 리스트컴프라는
사실을 알고 있을 겁니다.
그러나 여길 보세요.
튜플 컴프리헨션
이라는
것이 없다는 사실은 알지만 이 코드는 마치
튜플 컴프리헨션
처럼 보이네요. 게다가
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