|
そろそろとPythonをいじり始めた。
Python(x,y)をインストールするにあたり 今までのPythonインストール歴を真っ新にしなければならない。 なかなか身ぎれいにはならなかったので仕方なく荒治療、 Regedit で Keyword "Python"を検索して それらしいものを削除した。 おかげで Getting started with Python(x,y) にたどり着き すすめられるままに ”Python, Essential Reference”, David M. Beazley, Ed.: Sams Publishing, ISBN-13: 978-0-672-32862-6 ; をテキストに学習開始である。 目次によれば
I: The Python Language 1 A Tutorial Introduction 2 Lexical Conventions and Syntax 3 Types and Objects 4 Operators and Expressions 5 Program Structure and Control Flow 6 Functions and Functional Programming 7 Classes and Object-Oriented Programming 8 Modules, Packages, and Distribution 9 Input and Output 10 Execution Environment 11 Testing, Debugging, Profiling, and Tuning II: The Python Library
12 Built-In Functions 13 Python Runtime Services 14 Mathematics 15 Data Structures, Algorithms, and Utilities 16 String and Text Handling 17 Python Database Access 18 File and Directory Handling 19 Operating System Services 20 Threads and Concurrency 21 Network Programming and Sockets 22 Internet Application Programming 23 Web Programming 24 Internet Data Handling and Encoding 25 Miscellaneous Library Modules とあり、とりあえず第一部を適当に読み流せば
第二部は字引代わりに使えば良いさと 高をくくった。 第1-2章は足回りの説明で 配列はなくいきなりリストを使うなど贅沢感いっぱいである。 3章 Types and Objects First-Class Objectsに Dictionary {キー1:値1, キー2:値2, ...} を用いて 「値」といいつつ実はObjectなので items = { 'number' : 42, #ちなみにここで","がミスプリントで抜けています。 'text': "Hello World" } にとどまらず 関数 モジュール なんでもござれの例が示されている。 items["func"] = abs # Add the abs() function import math items["mod"] = math # Add a module items["error"] = ValueError # Add an exception type nums = [1,2,3,4] items["append"] = nums.append # Add a method of another object # items["func"](-45) # Executes abs(-45) 45 items["mod"].sqrt(4) # Executes math.sqrt(4) 2.0 # items["append"](100) # Executes nums.append(100) nums #[1, 2, 3, 4, 100] やりたい放題である。 実に嬉しくなるくらいPythonは自由度が高い(節操がない)。
|

>
- コンピュータとインターネット
>
- コンピュータ
>
- ソフトウェア







