Python Cookbook (2nd Edition) by Alex Martelli

By Alex Martelli

Preview
Portable, robust, and a breeze to exploit, Python is the preferred open resource object-oriented programming language used for either standalone courses and scripting functions. it's now getting used by means of more and more significant agencies, together with NASA and Google. up to date for Python 2.4, The Python Cookbook, second version deals a wealth of valuable code for all Python programmers, not only complex practitioners. Like its predecessor, the recent version offers ideas to difficulties that Python programmers face daily. It now comprises over two hundred recipes that diversity from basic projects, akin to operating with dictionaries and record comprehensions, to complicated initiatives, corresponding to tracking a community and construction a templating method. This revised model additionally contains new chapters on issues similar to time, cash, and metaprogramming. Here's an inventory of extra themes lined: * Manipulating textual content
* looking and sorting
* operating with documents and the filesystem
* Object-oriented programming
* facing threads and procedures
* approach management
* Interacting with databases
* developing consumer interfaces
* community and net programming
* Processing XML
* dispensed programming
* Debugging and testing
one other good thing about The Python Cookbook, second version is its trio of authors--three famous Python programming specialists, who're hugely noticeable on e mail lists and in newsgroups, and communicate frequently at Python meetings. With ratings of functional examples and pertinent heritage info, The Python Cookbook, second version is the single resource you wish if you're trying to construct effective, versatile, scalable, and well-integrated systems.
---
Alt. ISBN:9780596007973

Show description

Read Online or Download Python Cookbook (2nd Edition) PDF

Similar python books

Fundamentals of Python: From First Programs through Data Structures

In basics OF PYTHON: FROM FIRST courses via information constructions, Washington and Lee collage professor Kenneth A. Lambert offers all the very important subject matters in CS1 and CS2 in a single quantity. This low-cost structure offers teachers with a constant method of instructing introductory programming and information buildings over a regular two-term direction series.

Python for Data Analysis: Data Wrangling with Pandas, NumPy, and IPython

Python for facts research is anxious with the nuts and bolts of manipulating, processing, cleansing, and crunching info in Python. it's also a pragmatic, sleek advent to clinical computing in Python, adapted for data-intensive functions. this can be a ebook in regards to the elements of the Python language and libraries you'll have to successfully resolve a vast set of information research difficulties.

Python and AWS

Should you intend to take advantage of Amazon net prone (AWS) for distant computing and garage, Python is a perfect programming language for constructing functions and controlling your cloud-based infrastructure. This cookbook will get you all started with greater than dozen recipes for utilizing Python with AWS, according to the author’s boto library.

Artificial Intelligence with Python

Construct real-world synthetic Intelligence purposes with Python to intelligently have interaction with the realm round you approximately This e-book Step into the superb international of clever apps utilizing this accomplished consultant input the area of man-made Intelligence, discover it, and create your individual purposes paintings via basic but insightful examples that would get you up and operating with synthetic Intelligence very quickly Who This publication Is For This publication is for Python builders who are looking to construct real-world man made Intelligence purposes.

Additional info for Python Cookbook (2nd Edition)

Example text

Solution You can build a list whose items are the string's characters (meaning that the items are strings, each of length of onePython doesn't have a special type for "characters" as distinct from strings). Just call the built-in list, with the string as its argument: thelist = list(thestring) You may not even need to build the list, since you can loop directly on the string with a for statement: for c in thestring: do_something_with(c) or in the for clause of a list comprehension: results = [do_something_with(c) for c in thestring] or, with exactly the same effects as this list comprehension, you can call a function on each character with the map built-in function: results = map(do_something, thestring) Discussion In Python, characters are just strings of length one.

Processing a String One Character at a Time Credit: Luther Blissett Problem You want to process a string one character at a time. Solution You can build a list whose items are the string's characters (meaning that the items are strings, each of length of onePython doesn't have a special type for "characters" as distinct from strings). Just call the built-in list, with the string as its argument: thelist = list(thestring) You may not even need to build the list, since you can loop directly on the string with a for statement: for c in thestring: do_something_with(c) or in the for clause of a list comprehension: results = [do_something_with(c) for c in thestring] or, with exactly the same effects as this list comprehension, you can call a function on each character with the map built-in function: results = map(do_something, thestring) Discussion In Python, characters are just strings of length one.

When the pieces are not all available at the same time, but rather come in sequentially from input or computation, use a list as an intermediate data structure to hold the pieces (to add items at the end of a list, you can call the append or extend methods of the list). join(thelist) to obtain the big string that's the concatenation of all pieces. Of all the many handy tips and tricks I could give you about Python strings, I consider this one by far the most significant: the most frequent reason some Python programs are too slow is that they build up big strings with + or +=.

Download PDF sample

Rated 4.77 of 5 – based on 38 votes