Swaroop.CH--A_byte_of_python_115.pdf

(543 KB) Pobierz
A Byte of Python
A Byte of Python – www.python.g2swaroop.net
1
A Byte of Python
A Byte of Python
Swaroop C H
www.python.g2swaroop.net
Version 1.15
Copyright © 2004 Swaroop C H
This book is released under a Creative Commons License.
Revision History
Revision 1.15
28/03/2004
g2
Minor revisions
Revision 1.12
16/03/2004
g2
Additions and corrections
Revision 1.10
09/03/2004
g2
More typo corrections, thanks to many enthusiastic and helpful readers.
Revision 1.00 08/03/2004 g2
After tremendous feedback and suggestions from readers, I have made significant
revisions to the content along with typo corrections.
Revision 0.99 22/02/2004 g2
Added a new chapter on modules and about variable number of arguments in functions.
Revision 0.98 16/02/2004 g2
Wrote a Python script and CSS stylesheet to improve XHTML output, including a crude
lexical analyzer for syntax highlighting of the programs.
Revision 0.97 13/02/2004 g2
Another completely rewritten draft, in DocBook XML (again). Book has improved a lot -
It is more coherent and readable.
Revision 0.93
25/01/2004
g2
Added IDLE talk and more Windows-specific stuff
Revision 0.92
05/01/2004
g2
Changes to some examples, other improvements
Revision 0.91
30/12/2003
g2
Corrected some typos, improvised certain topics
Revision 0.90
18/12/2003
g2
Added 2 more chapters, OpenOffice format with revisions
Revision 0.60
21/11/2003
g2
747909231.003.png 747909231.004.png
A Byte of Python – www.python.g2swaroop.net
2
Fully Rewritten and Expanded
Revision 0.20
20/11/2003
g2
Corrected some typos and errors
Revision 0.15
20/11/2003
g2
Converted to DocBook XML
Revision 0.10
14/11/2003
g2
Initial draft using KWord
Abstract
The Perfect Anti-Venom for your programming problems!
This book will help you learn to use the Python language, whether you are new to
computers or are an experienced programmer.
747909231.005.png 747909231.006.png
A Byte of Python – www.python.g2swaroop.net
3
Dedication
This book is dedicated to each and every person in the free and open source
software community. They work hard to create such wonderful software and
technologies and share it with others. They selflessly share their knowledge and
expertise with us. The efforts of all the programmers, designers, artists, documentation
writers, bug-fixers and of course, the users, in creating such software and technologies
is truly inspiring and amazing.
 
A Byte of Python – www.python.g2swaroop.net
4
Table of Contents
Preface
Who This Book Is For
History Lesson
Status of this Book
Official Website
License Terms
I'd Like To Hear From You
Something To Think About
1. Introduction
Introduction
Features of Python
Summary
Why not Perl?
What Programmers Say
2. Installing Python
For Linux/BSD Users
For Windows Users
Summary
3. First Steps
Introduction
Using The Interpreter Prompt
Choosing an Editor
Using A Source File
Using a Source File
Executable Python programs
Getting Help
Summary
4. The Basics
Literal Constants
Numbers
Strings
Variables
Identifier Naming
Data Types
Objects
Logical and Physical Lines
Indentation
Summary
5. Operators and Expressions
Introduction
Operators
Operator Precedence
747909231.001.png
A Byte of Python – www.python.g2swaroop.net
5
Order of Evaluation
Associativity
Expressions
Using Expressions
Summary
6. Control Flow
Introduction
The if statement
Using the if statement
The while statement
Using the while statement
The for loop
Using the for statement
The break statement
Using the break statement
The continue statement
Using the continue statement
Summary
7. Functions
Introduction
Defining a Function
Function Parameters
Using Function Parameters
Local Variables
Using Local Variables
Using the global statement
Default Argument Values
Using Default Argument Values
Keyword Arguments
Using Keyword Arguments
The return statement
Using the return statement
DocStrings
Using DocStrings
Summary
8. Modules
Introduction
Using the sys module
Byte-compiled .pyc files
The from..import statement
A module's __name__
Using a module's __name__
Making your own Modules
747909231.002.png
Zgłoś jeśli naruszono regulamin