Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: Peter C. Norton, Alex Samuel, Dave Aitel, Eric Foster-Johnson, Leonard Richardson, Jason Diamond, Aleatha Parker, Michael Roberts

Rating No ratings yet

This tutorial offers readers a thorough introduction to programming in Python 2.4, the portable, interpreted, object-oriented programming language that combines power with clear syntax Beginning programmers will quickly learn to develop robust, reliable, and reusable Python applications for Web development, scientific applications, and system tasks for users or administrators Discusses the basics of installing Python as well as the new features of Python release 2.4, which make it easier for users to create scientific and Web applications Features examples of various operating systems throughout the book, including Linux, Mac OS X/BSD, and Windows XP

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
# Beginning Python: From Novice to Practitioner ## 【One-Line Pitch】 A hands-on, example-driven tutorial that takes absolute beginners from their first Python 2.4 script through object-oriented programming, file handling, and real-world application development—ideal for newcomers who learn best by typing code and seeing immediate results. ## 【Book Arc】 - **Opening (~0%–10%)**: Installation and first steps—getting the interpreter running, understanding strings, and mastering basic output with print statements and format specifiers. - **Early (~10%–23%)**: Core data types and control flow—numbers, variables, lists, tuples, dictionaries, and the while/for loop patterns that drive repetitive tasks. - **Early-Middle (~23%–39%)**: Functions and error handling—defining reusable code blocks, using docstrings, understanding the call stack, and raising exceptions for robust programs. - **Middle (~39%–48%)**: Object-oriented programming and modules—building classes like Fridge and Omelet, organizing code into importable .py files, and managing Python's module search path. - **Late (~48%–60%)**: File I/O and system tasks—reading/writing files, handling permissions, and practical examples like log file rotation for system administrators. - **Ending (~60%–100%)**: Advanced topics and professional practice—numerical programming with arrays, web services, licensing models, and porting code across platforms. ## 【Key Takeaways】 - **Strings are your first building block** (Opening): Master quote types, concatenation with +, and format specifiers (%s, %d) to display data—the foundation for all later output. (Early) - **Python enforces type consistency** (Early): The + operator only combines same-type objects (strings with strings, numbers with numbers), while format specifiers gracefully convert values for display—a key distinction for beginners. (Early) - **Lists are temporary data stores** (Early): Use append/extend to collect data in arrival order, then pop() to remove processed items—essential for handling streaming data like stock tickers or user input. (Early) - **while and for loops solve repetition** (Early): while tests a condition, for iterates over sequences; both automate tedious manual work and adapt to changing data automatically. (Early) - **Functions need documentation** (Early-Middle): Docstrings (accessed via __doc__) make functions self-explanatory, and raising exceptions (raise TypeError) gives precise error information to both users and calling code. (Early-Middle) - **Modules are just .py files** (Middle): Save any code as a named file (e.g., Foods.py), import it, and access classes via the module name (Foods.Fridge)—Python's sys.path controls where imports are found. (Middle) - **File rotation is a classic admin task** (Late): Rename oldest versions first (web.log.1 → web.log.2) to avoid overwriting, and use os.chmod for permission changes across platforms. (Late) - **Numerical programming scales up** (Ending): From integers to long integers, floats, complex numbers, and arrays (via array module or numarray), Python handles scientific computing with built-in math functions. (Late) ## 【Reading Tips】 - **Type everything yourself**: The "Try It Out" exercises are the heart of this book—don't just read them; run them in the Python shell to build muscle memory. - **Skim the theory, focus on examples**: Sections like "How It Works" explain what just happened; if you understand the output, move on quickly. - **Pay special attention to Chapter 7 (Organizing Programs)**: This is where the book shifts from toy examples to real code structure—modules and imports are essential for all later chapters. - **Use the omelet/fridge running example**: The recurring Fridge and Omelet classes tie together functions, objects, and modules—master this example and you've mastered the core language. - **Skip the licensing/business chapter if you're purely technical**: The final chapters on selling Python applications are useful for entrepreneurs but not essential for programming skills. ## 【Coverage Limits】 This guide covers the book's progression through Python 2.4 fundamentals, object-oriented programming, modules, file handling, and numerical computing. The excerpts do not cover the book's treatment of GUI development with PythonCard, web programming, or the detailed licensing/business chapters in depth. ##
Excerpt 1
Number 15 02_596543 ftoc.qxd 6/29/05 10:55 PM Page xxiii Contents Pure Python Licensing 387 Web Services Are Your Friend 388 Pricing Strategies 389 Waterm...
View in text
Excerpt 2
hat you can decide to give it a name that means some- thing. It is always worthwhile to give your data a name that reminds you of what it contains or how you...
View in text
Excerpt 3
the program, with a raise ... statement that makes it pos- sible for a problem to be either handled by functions or printed so that a user can read it: if ty...
View in text
Excerpt 4
\DLLs’, ‘D:\\Python24\\lib’, ‘D:\\Python24\\lib\\plat-win’, ‘D:\\Python24\\lib\\lib-tk’, ‘D:\\Python24’, ‘D:\\Python24\\lib\\site-packages’, ‘D:\\Python24\\l...
View in text
Excerpt 5
the names of each item you want to export from your module. For example, in the meal module, you can define __all__ in the following manner: __all__ = [‘Meal...
View in text
Excerpt 6
s.mkdir (os.path.join(“_test”, “subdir”)) f = open (os.path.join(“_test”, “file1.txt”), “w”) f.write (“””first line second line third line fourth line”””) f....
View in text
Excerpt 7
ny Wailer managed by Eric Foster-Johnson in qa How It Works The example output shows the before and after picture of the employee row, verifying that the upd...
View in text
Excerpt 8
to another or into any other text-based format. It is often used to transform XML into HTML in preparation for web presentation or a custom document model in...
View in text
Tags
AI categories
PythonProgramming LanguageProgramming
ISBN: 0764596543
Publisher: Wrox / Wiley Pub
Publish Year: 2005
Language: English
Pages: 679
File Format: PDF
File Size: 3.5 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…