Follow Slashdot blog updates by subscribing to our blog RSS feed

 



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:
  • by Dr. Smeegee ( 41653 ) on Monday November 06, 2006 @03:12PM (#16738981) Homepage Journal

    One might try out Alan Gald's fine Learning to Program [freenetpages.co.uk] site. Short on pretty. Long on usefulness.

    Oh, and all the thick books in the world will never help a budding python coder more than the tutor mailing list [python.org].

  • by leoPetr ( 926753 ) <leo.petr@g[ ]l.com ['mai' in gap]> on Monday November 06, 2006 @03:22PM (#16739137) Homepage Journal
    For that matter, the Official Python Tutorial [python.org] is doubleplusgreat. It's both well written and comprehensive.
  • I highly recommend (Score:1, Informative)

    by Anonymous Coward on Monday November 06, 2006 @03:35PM (#16739375)
    Guido van Rossum himself as well as Fred Drake wrote an amazingly concise and complete introduction to Python. This book will get you up and running quickly. The book is called "An Introduction to Python" and it can be found here (free html, a $5 pdf, or isbn):
    http://www.network-theory.co.uk/python/intro/ [network-theory.co.uk]

    This book is only 100 pages long! It was written for Python 2.2.2, but it is perfectly useful for any Python 2.x. This book is amazingly concise, but it is also quite complete. You will get the most out of this book if you have a background in C/C++.

    I am not affiliated with the book in any way, just a satisfied customer.

  • BN is overpriced (Score:3, Informative)

    by Electrum ( 94638 ) <david@acz.org> on Monday November 06, 2006 @03:39PM (#16739455) Homepage
    Save some money:

    Amazon.com [amazon.com] $32.99
    Overstock.com [overstock.com] $31.34
    Half.com [ebay.com] $28.95

  • Re:portable gui (Score:4, Informative)

    by jamwt ( 220439 ) <(moc.twmaj) (ta) (twmaj)> on Monday November 06, 2006 @03:43PM (#16739517) Homepage
    How about wxPython? [wxpython.org] Or, if you prefer, PyQT [riverbankcomputing.co.uk]? Both excellent.
  • Re:portable gui (Score:4, Informative)

    by Electrum ( 94638 ) <david@acz.org> on Monday November 06, 2006 @03:45PM (#16739575) Homepage
    I happen to use Linux, OSX and Windows, and the number one annoyance for me is a lack of clear "native-looking" GUI or OpenGL toolkit offering that is reachable by scripting languages like Perl and Python.

    wxPython [wxpython.org] is native on X11, Windows and Mac OS X.

    I used PyOpenGL [sourceforge.net] a few years ago and it was a very pleasant experience. It was easy to translate C examples to Python, without all the annoyances of using C. Obviously you wouldn't want to write a full game engine using Python, but it is nice for experimenting with OpenGL.
  • Re:portable gui (Score:4, Informative)

    by vivek7006 ( 585218 ) on Monday November 06, 2006 @03:48PM (#16739635) Homepage
    I happen to use Linux, OSX and Windows, and the number one annoyance for me is a lack of clear "native-looking" GUI

    QT [trolltech.com] with python bindings PyQt [riverbankcomputing.co.uk] will give you native looking GUI on all three platforms you are interested i.e windows, linux and OSX. Now QT4 is available as GPL even on windows, so its truly "free". QT also comes with QT-designer which IMHO is the best rapid GUI designer app.
  • Re:Python is SLOW (Score:2, Informative)

    by jamwt ( 220439 ) <(moc.twmaj) (ta) (twmaj)> on Monday November 06, 2006 @03:52PM (#16739711) Homepage

    ...and it need not be said.

    Between Pyrex [canterbury.ac.nz] and Psyco [sourceforge.net], there's really very, very few applications that a language like Python isn't appropriate for. Premature optimization is the far more common programmer sin these days than choosing a language that's "too slow." Except for a few, specific application domains (that only a minority of coders are writing) dynamic languages like python are an excellent choice on today's hardware. And if you need it to be faster, just profile, find the couple of spots that matter, and pull out Pyrex.. or even the C/Python API if it makes you feel manlier. :-)

    Plus, with things like PyPy [codespeak.net] + LLVM, Parrot [parrotcode.org], and IronPython [ironpython.com] emerging, things are only going to get better.. don't be the last one on the dynamic boat!

  • by yaphadam097 ( 670358 ) on Monday November 06, 2006 @04:07PM (#16739967)
    It is worth looking at the way that Python is used in the game industry. Quite a lot of shops use it in a heterogeneous environment where the core functionality, e.g. graphics, physics, control/hardware, etc are in highly optimised C with inline assembly but Python acts as a glue pulling them all together and scripting most of the actual gameplay. There are books on this, but it is more than just theoretical. I interviewed at a shop that does exactly this for the console games they produce.
  • Re:Python is SLOW (Score:2, Informative)

    by newt0311 ( 973957 ) on Monday November 06, 2006 @04:08PM (#16739981)
    hmm... I have had similar experiences but with lots ofspecial cases. in string processing, python is second to none. the lack of execution speed never shows up and writting string handling code in python is amazingly easy. Ditto in dbs. In numerical calculations though, python is a bad idea for anything except testing out an algorithm. thats because in python, everything even integers, floats, and chars are kept on the heap in pyobjects. so when somebody does x = y + z where y and z are integers, whats really hapening is that python is going to y and z, extracting the values, actually carrying out the operation, and then finally repacking the stuff back together. In defense, this super dynamicness does have some very useful results. namely that everything is dynamic including classes and functions which believe it or not, can actualy be useful sometimes.

    P.S. which algorithm competition allows python? really curious since I have always been pissed that these competitions don't accept languages like bash/ruby/python.

  • Re:Python is SLOW (Score:5, Informative)

    by kpharmer ( 452893 ) on Monday November 06, 2006 @04:21PM (#16740199)
    > It is just god-awful slow.

    Really? hmmm, my team runs a huge data warehouse in which all data is transformed via python programs. This means 40+ million rows a day get hash table lookups, business rule validations, type changes and various transformations.

    Then most of that data goes through an additional metadata-driven validation process that checks and confirms every single field. Again, metadata-driven - so a oouple hundred lines of various hash table lookups to determine exactly what validation applied to each field.

    Ok, now let's talk performance:
        1. io performance (most critical factor here)
                  a. same as c, in other words, extremely fast
        2. cpu performance
                  a. much slower than c, but workable
                  b. psycho helps a ton
                  c. the ability to rewrite key functions and classes is cool

    Let's also talk about productivity
        1. great for ease in training part-time or junior programmers
        2. great for immediately understanding old code
        3. great for writing robust test-driven code
        4. good for very quickly assembling a solution

    The above combo of ease of writing, ease of maintaining puts it far ahead of perl, tcl and java. Ruby is really the one other one in this niche I can think of off the top of my head. And even there Python appears stronger on the maintenance side.

    So, yeah - I'm sure there are many applications that have more significant performance requirements than ours does. But for this large application it is completely fine.
  • by CustomDesigned ( 250089 ) <stuart@gathman.org> on Monday November 06, 2006 @04:36PM (#16740479) Homepage Journal
    I use LiveWires [livewires.org.uk]. I teach a high school programming class with 7th graders. The adult oriented tutorial is a little too steep for them. They move along just fine with the LiveWires course. Also, the example projects are games. :-)

    An interactive (has an immediate mode prompt) language like Python is very helpful for first learning. BASIC used to fill that role, but I like starting with structured concepts. Kids have no problem "getting" that indentation marks blocks.

    Some experts hate python because while the grammar is "context free", the lexing isn't. The grammar is defined in terms of INDENT and OUTDENT taking the place of '{' and '}' (or BEGIN and END). However, whether a given indent is an INDENT or OUTDENT depends on context. So you can't use a traditional lexical analyzer when programmatically generating/modifying python code. You have to translate leading whitespace to INDENT and OUTDENT based on lexical context when parsing, and translate INDENT and OUTDENT to the appropriate amount of leading whitespace when pasting code blocks.

    Personally, I don't find that this is a problem. Sure 'lex' doesn't work out of the box, but the custom lexing code is pretty trivial. And the indentation sure is intuitive. Maybe that means I'm not an expert.

  • Re:Python is SLOW (Score:2, Informative)

    by MtHuurne ( 602934 ) on Monday November 06, 2006 @04:43PM (#16740609) Homepage

    The ICFP contest [icfpcontest.org] allows any language you want. It's once a year, with 3 days to work on the problem. Typically it's a single optimization problem for which a perfect answer is not feasible in terms of computation, so the best heuristic wins.

    The Internet Problem Solving Contest [ipsc.ksp.sk] also allows any language, since you only have to submit the output, not the program. It's also once per year. It has multiple problems and you have to solve as many as possible in 5 hours.

"Experience has proved that some people indeed know everything." -- Russell Baker

Working...