Python is a multipurpose development language that can be used on virtually every platform. It offers built-in support for critical development steps including data structures, dynamic typing, and dynamic building. It can be used in lieu of Java or C++, and Python scripts can be developed in a fraction of the time it takes to program and debug higher-level languages.\* Covers language basics and how to use Python for CGI scripting, GUI development, network programming, and much more\* Demonstrates why Python is arguably the most sophisticated of the popular scripting languages and why its popularity continues to grow Making Use of Python 2 Contents 6 Introduction 12 Overview of Python 13 History of Python 13 Features of Python 13 Users and Application Areas of Python 18 Python versus Other Languages 19 How This Book Is Organized 20 Who Should Read This Book 22 Tools You Will Need 22 What’s on the Web Site 22 Scenario 24 Techsity University 24 Course Structure 25 Fee Structure 25 Future Direction 26 An Introduction to Python 28 Getting Started 28 Understanding Requirements 29 Determine Requirements of the University 29 Obtain Python and Its Documentation 29 Determine the System Requirements 31 Install Python 32 Start Python in Different Execution Modes 34 Summary 39 Getting Started with Python 40 Getting Started 41 Writing Your First Python Program 41 Comments 42 Python as a Calculator 43 Using Variables in Python 43 Variables 44 Assigning Values to Variables 45 Standard Types 46 Identifiers and Keywords 66 Memory Management 67 Create a Sequence to Store All the Names of the Students 69 Write the Code to Display the Names of the Students 69 Declare a Dictionary of Student Purchases with the Names of the Students as the Key 70 Write the Code to Display the Student Purchases 70 Save and Execute the Code 70 Verify the Details 71 Summary 71 Intrinsic Operations and Input/Output 74 Getting Started 75 Using Input/Output Features and Intrinsic Operations for Data Types in Python 75 Identify the Variables to Be Used 76 Accepting User Input 76 Formatting the Output 77 Introduction to Intrinsic Operations 82 Intrinsic Operations for Numeric Data Types 84 Intrinsic Operations for Strings 87 Intrinsic Operations for Lists and Tuples 93 Write the Code 98 Execute the Code 98 Summary 100 Programming Basics 102 Getting Started 103 Conditional Operators 103 Order of Precedence of Operators 109 Using Programming Constructs 110 Identify the Control and Loop Statements to Be Used 111 Write the Code 121 Execute the Code 122 Summary 124 Functions 126 Getting Started 127 Using Functions 127 Functions 128 Scope of Variables 145 Identify the Functions to Be Used 146 Write the Code 146 Execute the Code 148 Summary 149 Modules 150 Getting Started 151 Using Modules 151 Modules 151 Packages 162 Identify the Modules to Be Used 163 Write the Code 164 Execute the Code 166 Summary 167 Getting Started 168 Files 168 Using File Objects 169 Identify the Functions and Methods to Be Used 169 Write the Code to Store Course Details to a File 181 Execute the Code 182 Verify the Solution 182 Summary 183 Object-Oriented Programming 184 Getting Started 185 Introducing OOP 185 Components of OOP 186 Benefits of OOP 187 Using Classes 188 Identify the Classes to Be Defined 189 Identifying the Class Objects 190 Identifying the Classes to Be Inherited and Their Objects 197 Identify the Methods to Be Overridden 200 Write the Code 209 Execute the Code 216 Summary 217 Exception Handling 220 Getting Started 220 Handling Exceptions 221 Identify the Type of Error and Where the Error Occurs 223 Identify the Mechanism of Trapping the Exception 227 Identify the Location for the Code for Handling 236 the Exception to Be Written 236 Write the Code for Handling the Exception 236 Save and Execute the Code 237 Summary 237 CGI Programming 240 Getting Started 240 Internet Basics 241 World Wide Web 244 Web Browsers 244 Hypertext Transfer Protocol (HTTP) 247 Revising HTML 248 Client-Side versus Server-Side Scripting 254 An Introduction to CGI 256 Write the CGI Program in Python to Generate the Results Page 258 Write the CGI Program to Generate Both the Form and Results Pages 262 Execute the Code 263 Summary 265 Database Programming 267 Getting Started 267 Database Management 268 Introduction to MySQL 269 Working with MySQL 272 Accessing a Database from a Python Script 280 Identify the Elements of the Table 282 That Stores Registration Details 282 Identify the Steps for Connecting to the Database 282 Write the Code to Create a Table in the Database 285 Write the Code to Insert the Registration Details 286 into the Table Created 286 Execute the Code to Create the Table in the Database 287 Execute the Code to Insert Data into the Table 287 Verify the Data in the Database 289 Summary 290 Network Programming 293 Getting Started 293 Client/Server Architecture 294 Network Programming 295 Using Sockets 298 Identify the Sockets to Be Used 298 Write the Code to Run on the IT Department Computer 313 Write the Code to Run on the Admission Office Computer 314 Execute the Code Created for the IT Department Computer 315 Execute the Code Created for the Admission Office Computer 316 Verify That Data Has Been Saved to a File in the IT Department Computer 318 Summary 318 Multithreaded Programming 323 Getting Started 323 Single-Threaded Applications 324 Threading in Python 325 Creating Multithreaded Applications 326 Identify the Class and the Methods to Create a Multithreaded Application 326 Write Code for the Server 334 Write the Code for the Client 335 Execute the Code Created for the Server 336 Execute the Code Created for the Client 337 Summary 339 Advanced Web Programming 341 Getting Started 342 Creating Web Servers 342 Accessing URLs 349 Creating Advanced CGI Applications 354 Identify the Elements of the Web Page for Entering 354 Assignment Details and Uploading the File 354 Identify the Methodology for Uploading the File 355 Identify the Methodology for Storing User Information 356 Write the Code for the CGI Script 361 Execute the CGI Script 365 Summary 366 GUI Programming with Tkinter 369 Getting Started 369 Introduction to Tkinter 370 Creating a GUI Application 373 Identify the Components of the User Interface 374 Identify the Tkinter Widgets to Design the User Interface 374 Write the Code for the User Interface 386 Execute the Code 388 Summary 390 Distributing COM Objects 391 Basics of COM 391 The Binary Standard 393 COM Interfaces 395 Binding 396 Python and COM 397 Creating COM Clients 397 Creating COM Servers 399 Index 403 End of Book 403
a Step-by-step Guide On How To Use Python For Cgi Scripting, Gui Development, Network Programming, And Much More!
organizations Such As Nasa, Hewlett-packard, And Xerox Have Already Discovered The Power That Python Has To Offer. This Multipurpose Development Language Can Be Used On Virtually Every Platform, From Windows And Linux To Os/2 And Amiga. With Its Unique Task-oriented Approach, This Book Explores The Language Basics And Then Describes How To Quickly Begin Using It For Development Work. Rashi Gupta First Explains Why Python Is Arguably The Most Sophisticated Of The Popular Scripting Languages And Why Its Popularity Continues To Grow. She Uncovers All Of Python's Unique Features, Detailing Its Built-in Support For Critical Development Steps, Including Data Structures, Dynamic Typing, And Dynamic Building. Gupta Then Discusses How To Use Python In Lieu Of Java Or C++ When Developing Cross-platform Applications. All In All, She'll Help You Gain The Skills Necessary To Begin Programming In Python.
with Numerous Real-world Examples And Expert Advice,this Book:
* Provides A Concise And Task-oriented Introduction To Python
* Helps You Evaluate The Suitability Of Python For Your Project
* Is A Practical Introduction To Python's Syntax And Fundamental Strengths
* Includes Numerous Working Scripts, With Information On How To Adapt And Extend Them To Meet Individual Needs
the Companion Web Site Contains:
* All Source Code From The Book
* Frequently Asked Questions, Quizzes, And Best Practices
* Links To Other Resource Sites
wiley Computer Publishing
timely. Practical. Reliable.
visit Our Web Site At Www.wiley.com/compbooks/
visit The Companion Web Site At Www.wiley.com/compbooks/makinguse
The Introduction familiarized you with Python.