Core Python Programming
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.
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.
Syntax wise it seemed like a fresh change from C-style languages. I'd use it again if I had a new project to do.
One might try out Alan Gald's fine Learning to Program 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.
Inherently flawed slow-as-fuck indentation-as-syntax (WTF!!!)
extremely poor Lisp wanabe.
Somebody was going to say it.
I'm just starting to learn programming, starting with Python. It's actually very easy, but you can do quite a lot with it. I also like that the interpreter's a small download, and easily available on the 3 different OS's (Windows for gaming, Mac at school, and Linux for work at home) a I use daily, which isn't the case, for, say, BASIC (As far as I've found).
has documentation too...
Reality is nothing but a collective hunch.
Unless Chun has changed the focus a lot, the book takes a fairly introductory stance on things. There's a lot of material explaining programming practices, OO and so on. If you're experienced with C/Perl/*nix development, you're probably better off with an O'Reilly book, or something else that has more reference material.
Where's the review? This was a sketchy synopsis. How about the writing style? Does the code use modern idioms? What did the examples cover -- are they real-world or contrived? Hell, is the typeface clear?
It's no wonder I skip straight to the comments -- these reviews are just about the most content-free section of slashdot.
Done with slashdot, done with nerds, getting a life.
Q: How many Python programmers does it take to screw in a lightbulb?
A: That joke's not funny.
After a year of fiddling with Python, I find I quite like it for some things, and it's not the right fit for other things. That's fine, there's no reason to be rabid pro- or rabid con- about any language.
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.
I'd like to see PyGame in a MacPort. The Images module was pretty easy to build but it should be in MacPorts too. I don't want to rely on X11 when on a Mac, but to use X11 when on Linux, which seems to be like bringing antimatter and matter together in the same universe. A GladeXML-like module that relies only on Aqua would be great.
Similarly on Windows, you're relegated to some fugly Tk choice if you want portable GUI. I can't think of a toolkit that looks less native than Tk, unless you count the early Java Swing "Metal" theme.
The fact that OSX still isn't standardized on python2.4 makes it hard to support python-rich applications like Blender, and we still run into problems where a 2.3 parser can't let scripts use 2.4 features (even smart scripts that try:except: to fall back gracefully). I think Leopard will be python2.4 but don't recall seeing official confirmation on that.
I'm sure I've misstated something technically-- I don't have my notes from home to double-check a few things from my last gui toolkit search a couple weeks ago.
[
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/
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.
Save some money:
Amazon.com $32.99
Overstock.com $31.34
Half.com $28.95
Python can be run on multiple Operating systems and system architectures which gives it the same portability of any interpreted language.
Eat shit you idiots. Python actually is an iterpred language. Stupid fuckers.
Python and its retarded syntax, what the hell where they thinking?
If you've ever written code before Dive into Python is the way to go. It is free on the web and also available in print from APress. I am a big fan of books of this style which assume that you already have some knowledge of basic programming and focus on the specifics of the new language.
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.
For anyone who has ever programmed before, the O'Reilly Python Pocket Reference is all that you need to start. I say that because Python is so simple to learn that I am afraid that some giant book might end up being a hindrance rather than an asset at the start. You might lose sight of just how simple a language it is- yet its very powerful and extensible. (the Pocket reference is around $9 or $10)
Might not work as a direct substitute, but Python also has an extensive online tutorial under the documentation section of their website, http://www.python.org./
Psyco 1.5 speeds up python 2.4.x to about 50% of java which is good enough to make most web apps I/O bound.
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.
I'm sorry but Python is a VERY easy language to learn plus inherently object oriented (although it impressively supports the functional paradigm as well). How is it that you can get all the way to chapter 13 in a book about python before talking about its OO features? I'm not seeing much value here...
Somebody was going to say that too.
Instead of saying all this, which is pretty much 90% FLUFF....
"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 example"
You could write....
Chapter 9 explains files.
same shit. just shorter. time is lines of code around here, cowboy.
http://wiki.python.org/moin/PythonSpeed
Lodragan Draoidh
The more you explain it, the more I don't understand it. - Mark Twain
I worked on a TP project in 2000. We converted the project from C to python, dropped 40,000 lines of code and bench-marked the python implementation as 3 times faster than the C implementation. The reason - we were able to focus on the problem when programming in Python, whereas in C we spent all our time (and code) getting it solid.
Few web-hosters have python to begin then. Then I read that for python to perform well requires mod_python 3.X, which in turn requires Apache 2.X. Practically no web-hosters use apache 2.x.
Popular frameworks like TurboGears, or Django, also require mod_python 3.x and apache 2.x.
No problem if you are developing internally, but if you want a hosted solution, I'm not sure if python is practical.
Python is a serious piece of problems for me:
"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."
Sounds like a typical spamvertisement really!
"Coupled with its ease of use"
umm hell, python is notoriously known for bad coders, writing broken applications based on underdeveloped and unmature modules, breaking forward compatibility.
Sadly enough, in the last two years, I have not seen any progress making python-based applications more stable. Programs like BitTorrent(!) have serious issues running on python-2.5(!)
"programs written in Python can be run on multiple Operating systems and system architectures which gives it the same portability of any interpreted language."
nothing new here, move along...
"My first brush with Python was when I tried out a beautiful game called PySol"
FOR CRYING OUT LOUD!!! Pysol is the ultimate proof that python programs are incredibly impossible to maintain forward because the library/module layer is so incredibly unmature. Pysol is no longer developed ! It doesn't even work with Python-2.4 !!! Even if the original developer stopped working on it, somebody should have been able to pick it up and maintain it easily, and the fact that this didn't happen is proof again that python is barring its own progress. See http://www.pysol.org/ - last release was in 2003.
Python has wasted my time as a packager/distro developer many many times, and ruined quite some weekends for me.
The world would be a better place without Python.
django and turbogears both run fine on apache1 too. or on lighttpd... or basically anywhere where there is fastcgi or scgi:
e nts
http://code.djangoproject.com/wiki/ServerArrangem
http://docs.turbogears.org/1.0#deployment
generally speaking, when you want to run a python web-application, you want to avoid to have to reload the whole application by every request.
because of this, CGI is not suitable, but there are many other ways:
- scgi
- fastcgi
- mod_python
- standalone python http servers (afaik turbogears and zope do this)
(of course, it's still true, that it's easier to find php-hosting than python hosting)
I don't know about python in general, but I have been going through the SciPy tutorials and plotting even a simple sine function and saving directly to file and not displaying a gui is about 20 times slower than piping data into grace or using pgplot and perl. My CPU usage spikes at 99% during the task, where as grace barely uses 10%. Matplot lib does some really great map projections that I would like to put in a web appp. But I'm having serious doubts. I may have to stick with piping data to grace.
One recent thread about the book (which also comments on why things like functions and OOP appear later in the book than one would think):r owse_thread/thread/b8366618c4547978
3 7 (it seems like Amazon, Buy.com, Bookpool, and Overstock rotate for having best overall price, i.e., no tax [depending on where you live] and free shipping)
http://groups.google.com/group/comp.lang.python/b
Also check the Amazon page for reviews and other feedback plus the author even posted a comment:
http://amazon.com/o/ASIN/0132269937
To reply to some previous comments:
- It's *much* faster than it used to be: http://shootout.alioth.debian.org/gp4/python.php
- The indentation only bothers you for 1-4 months. (I didn't like it either at first.)
- It *is* interpreted but byte-compiled like Java to make successive runs faster
- Why ESR likes Python: http://www.linuxjournal.com/article/3882
- Native look-n-feel GUI: http://wxwidgets.org/ and http://wxpython.org/
- Compare to other languages: http://wiki.python.org/moin/LanguageComparisons
- Shopping: http://www.bestbookdeal.com/book/compare/01322699
- Bad code: Python is attractive to first-time programmers because of its ease, so that's what you may be seeing. Also, bad code is language-independent, regardless; Python does not go out of its way to make this happen. However, Python also attracts long-time programmers because they discover they are more efficient and productive in it.
FWIW, I switched to Python a few years ago (after lots of C/C++, Java, Perl, Tcl, etc.), and I don't want to program in anything else again. The naysayers can pound on me all they like, but from my point of view, I enjoy what I do, I get decent pay, and I can get home on time to feed my kids then hack some more for fun after putting them to bed.
-A.C.
mod_python is most definately not a requirement, although it is an option, there are several other ways to host python web apps, and fastcgi
seems to be one of the more popular, there are also a large number of hosting providers that explicitly support python web apps , including
some that specialize in it.
"In Xanadu did Kubla Khan a stately pleasure dome decree"
Comment removed based on user account deletion
I prefer core programming in qore: http://qore.sourceforge.net/ :-)
Someone used "verily" on slashdot?!
Gushing review of 1000+ page book that can't even begin to be as concise as K & R... again.
Yawn.
Send the author back when they can get the size down to something the size of K & R while maintaining the same level of usefulness.
+++OK ATH
Reference counting memory management does not allow cyclic data structures, and since most programs have them (especially business apps with object models where nodes point to children or parent) or any GUI app (children widgets point to parent and vice versa), I fail to see how it is "easy to use". It is as easy to use as C++ with smart pointers, regarding memory management.
Read the FAQ. Python's garbage collector does check for cyclical references, just not as frequently (unless you tell it to via the gc module).
Ita erat quando hic adveni.
The book teaches the principles of Python programming by letting the reader create simple games. I found this method to be more concrete and rewarding than other books whose examples were very abstract. My one complaint is that the last three chapters on object oriented programing and gui graphic programing are a little confusing and use a watered down version of PyGames and LiveWires modules.
However, it provided me, a self-proclaimed programming idiot, a good solid foundation in the basics of programing.
The python command shell (and irb) is great. But it'd be nice to be able to edit multi-line commands when you make a typo and then be able to separate execution from core commands. If they would just add a line numbering scheme and some simple commands like 'RUN' and 'LIST', you'd have a truly modern work environment.
- You can't delete all the messages in one folder.
- The search function never works as intended (I want to look for messages only in one folder, damnit!).
So assuming this guy is very clever, Python must be broken or too dificult to use.
IANAL but write like a drunk one.
.pyc files are for python code translated into a python specific bytecode. .pyo files are an optimized version. The bytecode is interpeted by the python program in every case. It only loads faster because python translates the source code anyway, and has to convert from source to bytecode if you run a .py file alone. With pyc/o files, the first step is already done. Running directly from raw source would suck for many reasons--more complex and even slower.
The pyc and pyo files are not native machine code like what comes out of gcc or nasm. Native machine files don't require a separate program to run, though they need something to load them into memory and usually support libs. pyc/o files always require the python binary to run them in addition to any support modules.