Please create an account to participate in the Slashdot moderation system

 



Forgot your password?
typodupeerror
×

Core Python Programming 148

Ravi writes "Python, the dynamic object oriented programming language created by Guido van Rossum is known to deliver both the power and general applicability of traditional compiled languages without the complexities accompanying them. Coupled with its ease of use, programs written in Python can be run on multiple Operating systems and system architectures which gives it the same portability of any interpreted language. My first brush with Python was when I tried out a beautiful game called PySol — which is more like a collection of over 200 card games and PySol is entirely coded using the Python language. Nowadays a variety of Python web frameworks have also cropped up which promise the same kind of rapid application development that is possible using other programming languages." Read the rest of Ravi's review
Core Python Programming - 2nd Edition
author Wesley.J.Chun
pages 1050
publisher Prentice Hall
rating 9
reviewer Ravi
ISBN 0-13-226993-7
summary An excellent book to learn the Python programming Language


I found the book titled "Core Python Programming" authored by Wesley.J.Chun and published by Prentice Hall to be an ideal book to learn the wonderful Python language. This book is quite voluminous, with 23 chapters spanning 1050 pages. The book is divided into two parts the first part titled Core Python which contain 14 chapters which impart a sound understanding of the semantics of the language and the second part titled "Advanced Topics" which contain a collection of 9 chapters which give a good introduction to the specialized uses such as in database programming, network programming, using threads in python, GUI programming and so on.

In the first chapter of the book, the readers get to know the various features of Python and the steps needed to install Python on ones machine. When you install Python on your machine, it also provides its own shell where you can execute pieces of python code. The author has taken advantage of this functionality of Python in narrating the concepts throughout the book. Each concept and syntax is followed by bits of code which the readers can try out in the Python shell in its entity. I found this process much easier in learning this language as one need not go through the write — compile — execute cycle which is more prevalent in the traditional languages.

In depth coverage has been provided for important concepts such as lists, tuples and dictionaries as well as data-types and string sequences and they have been provided separate chapters of their own. The sixth chapter titled "Sequences: Strings, Lists and Tuples" is the second largest in the book and is quite detailed in its coverage of the topic.

Chapter 9 deals with file manipulations where the author introduces all the built in functions available in Python which allow one to open, read from and write to a file. Interestingly, the functions are also illustrated by aid of short easy to understand examples. A couple of modules related to file handling are also introduced in this chapter.

Errors and exceptions form the basis of the 10th chapter where different errors and exceptions supported in Python are explained. This chapter also explains how programmers can create custom exception classes which I found quite informative.

One of the biggest advantages of Python is that all its functionality is split up into modules. A module could be just a single python file which contain a collection of functions or classes which can be re-used in programs written in Python. And all one has to do is import the module into ones programs to start using those pieces of code. The chapter 12 titled Modules give a firm understanding of this concept and also introduces different ways in which you can import external pieces of code into the Python program.

Chapter 13 titled "Object Oriented Programming" is by far the largest chapter in this book and spans over 100 pages. In this chapter, the author endeavors to give a sound base to Object oriented concepts as well as how they relate to programming in Python. The author introduces a large number of Python classes, methods and descriptors in this chapter.

Regular expressions play a very important part in programming verily because manipulating text/data is a necessity. And it is possible to easily modify and mould data to ones choosing by way of regular expressions. Python has strong support for regular expressions. The second part titled "Advanced concepts" of the book starts with a chapter on regular expressions. In this chapter, one gets to know about the regular expression module and many functions associated with the module. The author also provides a couple of examples which give insights into the ways in which regular expressions can be used in Python to reformat data.

The next two chapters give an introduction to the world of sockets and how Python can be used to write client server programs.

Multithreaded programming forms the basis of the 18th chapter. Here the author introduces a couple of modules available in Python which make it quite easy to create threads in ones Python program.

I found the chapter titled "Web Programming" very interesting to read. Especially since Python is used in a large way to create dynamic websites. And the next chapter titled "Database programming" gives a sound introduction to the Python objects which allow one to easily connect to and retrieve data from the databases.

I found this book really informative, especially suited for upcoming Python programmers. At the end of each chapter, there is an exercise section which imparts a nice touch to this book as it allows you to test your knowledge. Even though the advanced topics (second part of the book) are not covered in depth, the author succeeds in providing enough knowledge about the relevant Python modules and functions followed by a couple of examples which whets ones appetite without overwhelming the reader. This is the second edition of the book and it has been significantly revamped to include new features introduced in Python 2.5.

The author Wesley J. Chun has been a former employee at Yahoo and has played a major role in creating Yahoo Mail and Yahoo People Search using Python. He has over 20 years of experience in the IT field with over a decade of experience programming in Python.

Ravi Kumar likes all things related to open source and free software and enjoys sharing his experiences and thoughts through his blog All about Linux.


You can purchase Core Python Programming - 2nd Edition from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
This discussion has been archived. No new comments can be posted.

Core Python Programming

Comments Filter:
  • Re:Python is SLOW (Score:3, Insightful)

    by BlackPignouf ( 1017012 ) on Monday November 06, 2006 @03:27PM (#16739229)
    Sometimes it's worth spending nights writing and optimizing C programs to gain just a few milliseconds, sometimes you just need to write a small script in either Python or Ruby to automatize a task you'll never do again.
    In this case, would you really care about execution speed? I'll just go for the ease of string/files/array/hashes manipulation, write a powerful script in 10 minutes and go drink a coffee while my script works for me and you're still struggling with your char str[80];.
  • Re:Python is SLOW (Score:3, Insightful)

    by marcog123 ( 969158 ) on Monday November 06, 2006 @03:51PM (#16739699) Homepage

    It really depends on the application. Python is really easy to use and for applications that aren't cpu/io intensive it could prove better to use over a language such as C just because it's much easier and quicker to put together something relatively small together. However, once the requirements start to grow it's a completely different scenario. As soon as you're going to be writing an application that's going to take a few seconds to execute an operation, then a faster language such as C might be a better solution.

    I am quite involved in algorithm competitions and have for the past couple of years started helping in the setup of a few. One of them recently introduced Python as amoungst the original C/C++, Java and Pascal. From this I got a good experience in the speed differences between the four languages.

    C/C++ and Pascal have always been pretty much neck-and-neck as the fastest, with Pascal just loosing out. Java used to be about 3-4 times slower, but it has been improving over the past couple of years and now with 1.5 it is about 1.5 times slower than C/C++ and Pascal. Not too bad when you take everything into account. With Python however, the gap varies tremendously. In some cases it's less 3-4 times slower (comparing to C/C++ from here on), but in some cases it's as bad as 100 times slower!!! And that's taking the exact same algorithm, the exact same code even and translating it between the four languages!

    My conclusion is that while Python is slow, the decision as to whether to use it or not depends on the problem.

  • Re:Python is SLOW (Score:1, Insightful)

    by Anonymous Coward on Monday November 06, 2006 @04:04PM (#16739915)
    Its simply not true that Java is "far slower" that Python. And Java gets "all the ink" because its not only a fast language, but also has proven again and again it can scale very well on many different levels.
  • Re:Python is SLOW (Score:2, Insightful)

    by MtHuurne ( 602934 ) on Monday November 06, 2006 @04:23PM (#16740233) Homepage
    Is a car slow because an airplane is much faster? If you're going to write a ray tracer or a weather simulator, C++ would be a better choice than Python. If you're going to write a server than has to deal with a dozen requests per second, a simple game, a GUI app, a code generator or anything else that will not stress your CPU to its limits, Python is fast enough. And you will win in productivity: no compile/link phase, far less code to write, exceptions instead of crashes when your program fails.

    The key to getting good performance out of Python is to know and use the libraries well. Most of the performance sensitive library calls are implemented in C and have been optimized. As long as you use those instead of reinventing the wheel, you will get pretty decent performance from Python. Python's standard library is very complete ("batteries included"), for example it includes a unit testing framework and a profiler.

    Additionally, by being able to implement things in a small amount of code, you'll get a better overview of what your program is doing. This means it is easier to spot where the performance bottlenecks are. If your program is so complex that you don't realize you're using an O(N*N) algorithm where O(N*ln(N)) is also possible, no fast compiler will be able to compensate for that unless your data sets are really small.
  • Re:Python is SLOW (Score:3, Insightful)

    by Hugonz ( 20064 ) <hugonzNO@SPAMgmail.com> on Monday November 06, 2006 @04:44PM (#16740647) Homepage
    Then dont pretend that Python is an all purpose programming language and admit/accept it for what it really is : An overhyped, scripting language, a better PERL in some aspects if you will.

    It *is* a general purpose programming language. Well, it is as well suited to 3d games programming as C is to a web application; and nobody would dare to say C is not a general purpose programming language.

    I know you said "all purpose programming language", but then again, for that matter no language is "all purpose" (not even all-purpose flours are really that)

    Based on my own experience, I wouldn't say Python is overhyped, and it IS a MUCH MUCH, MUCH better Perl (I used Perl for 2 years, discovered Python and never looked back.)

    You called Python a "scripting language". What newer language or implementation runs on the bare hardware, or the bare OS Libraries, apart from C/C++... let's see: Java? nope, VB? nope any .NET Language? NOPE You see a pattern there?

The hardest part of climbing the ladder of success is getting through the crowd at the bottom.

Working...