Skip to Content
『Learning Python 第6版』
book

『Learning Python 第6版』

by Mark Lutz
March 2025
Intermediate to advanced
1172 pages
24h 57m
Japanese
O'Reilly Media, Inc.
Content preview from 『Learning Python 第6版』

第3章. プログラミングの実行方法

この作品はAIを使って翻訳されている。ご意見、ご感想をお待ちしている:translation-feedback@oreilly.com

さあ、コードを実行する時が来た。Pythonの目的と実行モデルを理解したところで、いよいよ本格的なPythonプログラミングを始める準備が整った。

Pythonに入力したコードを実行させる方法は複数あり、この章では現在一般的に使われている主要なプログラミング起動テクニックをすべてカバーする。その過程で、コードを対話的に実行する方法と、それをファイルに保存してコマンドライン、アイコンのクリック、IDLE GUI、モバイルアプリ、Webインタフェース、モジュールのインポートなど、さまざまなテクニックを使って実行する方法を学ぶ。

前章と同様、もしプログラミングの経験があり、Pythonそのものを掘り下げていきたいと思っているのであれば、この章を読み飛ばして第4章に進んだ方がよいかもしれない。しかし、この章の序盤にある前置きと規約、デバッグテクニックの概要、モジュールのインポート(Pythonのプログラムアーキテクチャを理解するために不可欠なトピックで、第V部まで再訪しない)を読み飛ばさずに読んでほしい。また、IDEとアプリのセクションを参照し、より大きなプログラムをコーディングし始めたときに役立つかもしれないツールのサンプルを見ておくことも価値がある。

Pythonをインストールする

本書では一般的に、コンピューター、タブレット、携帯電話で最新バージョンのPythonにアクセスできることを前提としている。Pythonのインストールは本書では必須ではないし、文脈によっては必要ない場合もあるが、例題に沿って作業したり、パート末の練習問題を解いたりするためにはPythonが必要であり、どちらも概念をより具体的にするための素晴らしい方法である。

もしPythonを持っていなくてセットアップしたいのであれば、プラットフォームごとのインストールのヘルプは付録Aを参照のこと。要するに

  • Windowsと macOSユーザは、 、デバイスにPythonをインストールするセルフインストール実行ファイルを実行する。ダブルクリックし、すべてのプロンプトで「はい」か「次へ」と言うだけだ。

  • Linux(WindowsWSLを含む) ユーザは、ユーザビリティのあるPythonがコンピュータにプリインストールされているかもしれないが、必要であればディストリビューションのリポジトリからインストールすることができる。

  • Androidと iOSユーザは、携帯電話やタブレット上でPythonをローカルに実行できるアプリをインストールする。

  • Unix(とLinuxの一部)ユーザは、しばしば、Pythonをその完全なソースコード配布パッケージからコンパイルする。

例えば、スマートフォンユーザーはアプリストアでPythonアプリを入手し、WindowsやmacOSのPCユーザーはPythonのメインWebサイトのダウンロードページでインストーラーを入手する。Pythonは他の流通経路でも入手できるかもしれないし、Jupyterノートブックなど、この先で取り上げるPythonのコーディングモードには、独自のインストール手順や使用手順がある。文脈によってはPythonのバージョンを選択できないかもしれないが、本書ではPython 3.12を使用しているので、それに近い方がいいだろう。

インストールする前に、一般的にPythonが既に存在するかどうかを確認する必要がある。Windowsではスタートメニューから、ほとんどのプラットフォームでは ...

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

Python Polars ―高速なデータ処理を実現する次世代ライブラリ

Python Polars ―高速なデータ処理を実現する次世代ライブラリ

Jeroen Janssens, Thijs Nieuwdorp, 中田 秀基
入門 Python 3 第2版

入門 Python 3 第2版

Bill Lubanovic, 鈴木 駿, 長尾 高弘

Publisher Resources

ISBN: 9798341634367