Beta

Slashdot: News for Nerds

×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Core Python Programming

samzenpus posted more than 7 years ago | from the code-it dept.

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

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.

cancel ×

148 comments

Python (0)

Anonymous Coward | more than 7 years ago | (#16738891)

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.

Re:Python (0)

Anonymous Coward | more than 7 years ago | (#16739363)

"Syntax wise it seemed like a fresh change from C-style languages"

There is a little C heritage in Python.

print "My app, %s, is %i times more portable now" % (sys.argv[0], 10)

Re:Python (2, Interesting)

cortana (588495) | more than 7 years ago | (#16740801)

And I'd been using that for years before I bothered to read the documentation and discovered:

<pre>print '%(imperative)s, a %(adjective)s %(noun)s!' % {'imperative': 'Look!', 'adjective': 'built-in', 'noun': 'templating system'}</pre>

Re:Python (2, Interesting)

WoLpH (699064) | more than 7 years ago | (#16742623)

I hope you'll forgive me for posting so much code (well, it's slashdot after all), but something like that can be very useful, here's another example on how to separate your code and your variables easily.

>>> spam = {}
>>> spam['eggs'] = 'some eggs'
>>> spam['beans'] = 'beans!'

>>> 'The eggs: %(eggs)s' % spam
'The eggs: some eggs'
>>> 'Everything in spam: %s' % ', '.join(spam)
'Everything in spam: eggs, beans'

On the cheap side ... (4, Informative)

Dr. Smeegee (41653) | more than 7 years ago | (#16738981)

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] .

Re:On the cheap side ... (1)

AxXium (964226) | more than 7 years ago | (#16739071)

Thanks a bunch for that tip on the mailing list list! :)

Re:On the cheap side ... (1)

Dr. Smeegee (41653) | more than 7 years ago | (#16739203)

It sure is handy! One can actually get decent advice from at least one O'Reilly book author who posts pretty regularly. It's very low-noise and calm. I have never seen a RTFM. :-)

Re:On the cheap side ... (4, Informative)

leoPetr (926753) | more than 7 years ago | (#16739137)

For that matter, the Official Python Tutorial [python.org] is doubleplusgreat. It's both well written and comprehensive.

For younger children... (3, Informative)

CustomDesigned (250089) | more than 7 years ago | (#16740479)

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:On the cheap side ... (0)

Anonymous Coward | more than 7 years ago | (#16739373)

Byte of Python [byteofpython.info] and Dive Into Python [diveintopython.org] are also worth looking at.

Dive Into Python rules! (1)

yaphadam097 (670358) | more than 7 years ago | (#16739845)

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.

I highly recommend (1, Informative)

Anonymous Coward | more than 7 years ago | (#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.

Re:On the cheap side ... (1)

hcdejong (561314) | more than 7 years ago | (#16739549)

I've been using How to think like a computer scientist: Learning with Python [greenteapress.com] . It's useful, but a bit terse. My programming skills are rather limited and rusty, so I got stuck halfway through the book. People who program for a living will find the book easy to digest, I expect.

Re:On the cheap side ... (0)

Anonymous Coward | more than 7 years ago | (#16740161)

That's because terseness is one of the fundamental attributes of a computer scientist. You'll pick it up eventually.

Python sucks (-1, Flamebait)

Anonymous Coward | more than 7 years ago | (#16738995)

Inherently flawed slow-as-fuck indentation-as-syntax (WTF!!!)
extremely poor Lisp wanabe.

Re:Python sucks (2, Interesting)

philgross (23409) | more than 7 years ago | (#16739483)

So, I was going to mod you Troll, but I decided to respond instead, since I think a lot of people are under the same misapprehensions as you are.

Regarding the indentation-as-syntax, consider the following C code, where someone tried to add the baz() function to a loop:

while (foo())
    bar();
    baz();


This code has an obvious bug. Baz() is not in the loop body, because the braces are missing. It's obvious from the indentation that that was the coder's intention. Why does one need an orthogonal and error-prone syntax for marking basic blocks, when the formatting already makes the intention obvious?


Or, consider this example from the paper Algorithm Education in Python [uci.edu] :


Here is the Insertion Sort algorithm exactly as presented in Cormen, Leiserson, Rivest, and Stein's "Introduction to Algorithms":

Insertion-Sort(A)
    for j <- 2 to length[A]
        do key <- A[j]
        i <- j - 1
        while i > 0 and A[i] > key
            do A[i+1] <- A[i]
            i <- i - 1
        A[i + 1] <- key


Here is the same algorithm, implemented in Python:

def InsertionSort(A):
    for j in range(1, len(A)):
        key = A[j]
        i = j - 1
        while (i >=0) and (A[i] > key):
            A[i+1] = A[i]
            i = i - 1
        A[i+1] = key

I haven't left anything out. Paste that into a Python interpreter and run it:

>>> x = [2,7,3,8,1] # create test case
>>> InsertionSort(x) # call routine
>>> x # look at result
[1, 2, 3, 7, 8]

There are about a thousand other cool things, and of course there are inevitably some warts and poor design decisions too. Bottom-line for me, at least, it's the power of Perl, but at the extreme other end of the spectrum in terms of readability. The Google folks think so too.

Re:Python sucks (1)

Ecks (52930) | more than 7 years ago | (#16741433)

Once you've actually used the python for any period of time you come like this feature. In reality whitespace does matter. When a person reads a block of code, what the person thinks the code does is at least as important if not more important than what the compiler/interpeter builds the code to do. Making whitespace a functional part of the code just aligns the reader and the interpeter/compiler which removes a source of errors.

Re:Python sucks (1)

sowth (748135) | more than 7 years ago | (#16741977)

So many editors switch tabs/spaces freely which creates problems with indentation syntax. Because of python and make, I have reverted to using e3 as an editor. I like that it is small and simple, but it does not have anything fancy like syntax highlighting. For programming syntax highlighting helps a lot. I used jed before and loved it, but it mucks with spaces and tabs, so python and make wouldn't work. Yeah, I think you can change the settings to make it work, but it is a huge pain in the ass.

Python is SLOW (-1, Flamebait)

timeOday (582209) | more than 7 years ago | (#16739085)

Somebody was going to say it.

Re:Python is SLOW (3, Insightful)

BlackPignouf (1017012) | more than 7 years ago | (#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 (0)

Anonymous Coward | more than 7 years ago | (#16739285)

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.

People who complain about speed issues with Python are not creating
3d engines or trying to squeeze milliseconds out of their algorithms.
They fall for the hype and try to create general-purpose applications
only to be extremely disappointed in the end (that is if they are objective)

Re:Python is SLOW (3, Insightful)

marcog123 (969158) | more than 7 years ago | (#16739699)

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 (0)

Anonymous Coward | more than 7 years ago | (#16739775)

Maybe you shouldn't take the algorithm and use it direct? Each language has a way of doing things and some special methods for major speed boosts. Look at the number of python programs around coding up the usual way and never any list comprehension in site which would dramatically speed that part of the code up.

Re:Python is SLOW (1)

marcog123 (969158) | more than 7 years ago | (#16739887)

I had a couple of people check the code in the case where it was 100 times slower and the best they could do was reduce the time from 30 seconds to 28 seconds. On top of it none of the students that participated could get their Python solutions any faster. So it wasn't the case of not using the most efficient functionality.

Re:Python is SLOW (1)

sowth (748135) | more than 7 years ago | (#16742233)

That is why they allow you to link with components in C. The critical time components can be written in C while the rest can stay Python, if you want. I think python is more useful for prototype design or just quick scripts. I agree it is slow, but it would be faster if someone made a compiler--I think someone did make a JIT one, but for one off things JITC is slow too. Some components don't need to be blazing fast, but an interpeter sucks with slowness.

Re:Python is SLOW (2, Informative)

newt0311 (973957) | more than 7 years ago | (#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 (1)

marcog123 (969158) | more than 7 years ago | (#16740589)

> 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.

Another big issue is the memory usage. Man is Python a memory hog! For a list of integers it takes up about 20 bytes per integer! Now you just imagine the processing overhead of managing all that additional data. On top of that it has to go figure out what types are used in before it can perform the operation - and this is all happening at runtime.

> 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.

I agree 100% with you on that point. And this is one of the reasons I believe Python is where it is. It's one of the easier languages in which you can use functional programming.

> 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.

Unfortunately it's not one I think you'd be participating in. It's a South African only event and the only reason we have Python is because of Mark Shuttleworth pumping in the money. As an organiser it's a painful language to have to support, simply due to the not-so-easy-to-measure speed difference. Last year we had a 10x time factor and this year a 5x time factor while dramatically reducing the constraints on some of the slower Python problems.

Re:Python is SLOW (2, Informative)

MtHuurne (602934) | more than 7 years ago | (#16740609)

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.

Re:Python is SLOW (1)

tdelaney (458893) | more than 7 years ago | (#16740107)

It also depends heavily on whether you're using idiomatic Python. If you're doing a straight translation of algorithms from another language, chances are you're unnecessarily introducing performance problems. Quite often, the optimal approach in C/C++/Java is not the same as it is in Python. Often the "obvious" approach in Python is the fastest (in particular - use the built-in types!).

For example, in C/C++/Java a switch is often the fastest way to make a multi-choice decision. Python does not have a switch, and so Python beginners tend to use an of if/elif[/elif...]/else statement. A better way to do this is to encapsulate each branch into a function, then build a dictionary of values to functions (once - there's no point building the dictionary every time), then simply do a dictionary lookup and call the result.

Also, check out Psyco: http://psyco.sourceforge.net/ [sourceforge.net] - it can often give a significant speedup.

However, most of the time Python will be significantly slower than well-optimised C/C++/Java. OTOH, because Python is so easy to write, it's a lot simpler to get it right first, then optimise.

Re:Python is SLOW (1)

marcog123 (969158) | more than 7 years ago | (#16740885)

Read my post above wrt the use of particular features of Python improving performance.

As for the switch statement in C/Java, it's actually no longer any faster then a bunch of if statements since the modern compilers optimize them to the same machine code. As for Python though it's a different story since it's interpreted. Building up a dictionary might actually be faster, but I would have to test it out first before accepting it as fact.

> OTOH, because Python is so easy to write, it's a lot simpler to get it right first, then optimise.

Don't get me wrong, I really like Python. I'm just highlighting the fact that it's better suited to particular applications than others.

Re:Python is SLOW (1)

nuzak (959558) | more than 7 years ago | (#16741961)

> As for the switch statement in C/Java, it's actually no longer any faster then a bunch of if statements since the modern compilers optimize them to the same machine code.

I think you mean that some compilers may optimize a bunch of if statements into jump tables, the same way they've been doing for switch for well over a decade. Python could perhaps do jump table optimization for a switch opcode, but you'd be micro-optimizing something that would either barely benefit or would benefit more from a redesign to proper OO or functional code. Switch is a crappy primitive construct with marginal expressive utility -- now if Python had ML or Erlang-style pattern matching, then we'd be talking.

Re:Python is SLOW (1)

Lodragandraoidh (639696) | more than 7 years ago | (#16742053)

As for Python though it's a different story since it's interpreted.

Actually, Python is byte-code compiled at run-time. You can see this in action after you run a Python app one time, you will see a .pyc file - that is the compiled version which gets executed by the Python virtual machine.

Re:Python is SLOW (1)

Lodragandraoidh (639696) | more than 7 years ago | (#16740761)

Also remember - taking the exact same algorithm between different languages may be misleading. In the case of python, there are more 'pythonic' language constructs that obviate the need to use particular algorithms - and also may provide speed above and beyond what you would find using the traditional algorithm.

So, this, for instance, is a Pythonic way of getting multiple return values from function:

      def something():
              return "Foo", "Bar"

      foo, bar = something()

whereas this is not:

      def something(l):
              l.append("Foo", "Bar")

      l = []
      something(l)
      foo = l[0]
      bar = l[1]

Someone coming from a language like C or C++ might however have designed something like the latter.

Here is a link to comparisons of python with other languages for your edification: [python.org] http://wiki.python.org/moin/LanguageComparisons [python.org]

Re:Python is SLOW (2, Insightful)

Hugonz (20064) | more than 7 years ago | (#16740647)

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?

Re:Python is SLOW (1)

sowth (748135) | more than 7 years ago | (#16742457)

Scripting language just means it is interpeted. That is why python is slow. If they made a compiler for python, it would be much faster, though likely not as fast as C.

Re:Python is SLOW (1)

blueskies (525815) | more than 7 years ago | (#16743309)

What are the pyc files for?

Re:Python is SLOW (1)

WilliamSChips (793741) | more than 7 years ago | (#16742083)

A minority of applications are actually CPU-bound. Most applications are I/O-bound and can't be optimized. Most "general purpose" applications won't benefit from being written in C.

Re:Python is SLOW (1)

baadger (764884) | more than 7 years ago | (#16739413)

Not necessarily a "char str[80]". Many people forget that C++ isn't just "C that lets you do proper OOP", it's a better C and plenty of string classes, file access classes, array and hash classes exist for C++.

Of course I doubt any of them are as easy to use as Python... but I wouldn't mind betting there are some C++ library guru's out here in the /. crowd familiar with enough to whip up something almost as quick as you can in Python.

Re:Python is SLOW (0)

Anonymous Coward | more than 7 years ago | (#16740223)

Not so sure. I am a C++ guru, and I still reach for Python first in most cases. It's without a doubt the language that enable me to express the problem that I'm working on in the most clear and succinct fashion. Furthermore, it has certain features that don't really have obvious counterparts in C++, such as generators and list comprehensions, that I find extremely useful.

And when I really need speed for that expensive inner loop, or image processing algorithm, or whatever, I just reach for boost::python [boost.org] and incorporate my C++ code nicely exposed as Python functions and classes.

Re:Python is SLOW (1)

supersnail (106701) | more than 7 years ago | (#16741115)

Well C was written as a readable assembly language and there
has been 20 plus years of optimisation going on there, so,
you have got to be a shit hot assembly programer to beat pure
C on speed.
C++ is considerably slower and harder to read ( flambait ;-).

The interesting thing is that well written Pyhon applications
run about the same speed as well written Java.

The key phrase here is "well written" and you really do have to
be aware of what pyhon is doing the classic being
  python " for x in range(1,1000)"
  is not the same as C "for (x=1;x1000;x++)"

    The python statment actually means
                " build a list consisting of all the numbers from 1 to 1000
                    then for each entry in the list assign it to 'x' and do the
                    loop body "
This is obviously going to be slow compared with a classic for loop
and I have seen this statement used in many a brain dead performance
comparision.

Also note that in real life C and C++ solutions can actually be
slower than Python because its just to complicated to code stuff
like a dictionaty of functions which is all built into python.

So write it in Python and if you have a performance problem
write better Python and if you still have a performance problem
write it in C.

Re:Python is SLOW (1)

marcog123 (969158) | more than 7 years ago | (#16741365)

> python " for x in range(1,1000)"
> is not the same as C "for (x=1;x1000;x++)"

In place of range(), you should use xrange() [python.org] as it doesn't build up the whole list as range() does.

Re:Python is SLOW (0)

Anonymous Coward | more than 7 years ago | (#16742229)

I'll takle the flamebait! Studies have shown that C++ can be faster than C. I don't have the links and would be happy to simply remove considerable from your statement. C++ is about the same as C for speed. In some cases a little faster, in others a little slower. If it is considerably slower than the code was not well written in the first place. It may well be true that, in general, C programs tend to be faster as the language is smaller and less likely to confuse the programmer with advanced features. I suppose any program you write in python, I can write to be slower in C++, and to be even slower with C. This reflects my genius and not the quality of the C++/C programs I have produced. Inherently, well written C/C++ will be faster than python, but it may well be faster to write the application in python. If my server is not a busy server, why should I care about the application speed? I will be more concerned with my programming speed. If my server is busy I might well prefer funding the overtime to have the application well written in C/C++. In reality the trade-off between C/C++ and python isn't about speed or development time but strong typing.

Re:Python is SLOW (1)

shmlco (594907) | more than 7 years ago | (#16743359)

So a beginner programming in Python has to known the internal implementation details of every function?

Re:Python is (not) SLOW (2, Informative)

yaphadam097 (670358) | more than 7 years ago | (#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 (2)

CoolCat23 (923066) | more than 7 years ago | (#16739361)

  • First, as far as web programming is concerned, the users are always slower than the slowest of all programming languages : they read the text, fill in the forms, etc.
  • Second, as Python is used in games to implement AI, so I guess it isn't THAT slow.
  • Third, "scripting language = slow" has been proven false for long now...

Re:Python is SLOW (1)

Decaff (42676) | more than 7 years ago | (#16739617)

# First, as far as web programming is concerned, the users are always slower than the slowest of all programming languages : they read the text, fill in the forms, etc.

What matters is how fast responses are once forms are submitted.

# Second, as Python is used in games to implement AI, so I guess it isn't THAT slow.

Python is almost always (when used in this circumstance) used to script what happens in game AI, not the AI itself. When Python is used for such coding, performance-critical functions are usually implemented in C or C++.

Third, "scripting language = slow" has been proven false for long now...

If this were true, then developers needing performance would not need to implement extensions in C or C++.

Re:Python is SLOW (1)

suitepotato (863945) | more than 7 years ago | (#16739535)

And Java is far slower yet it gets all the ink why? Because Sun was seen as an upstart taking on Microsoft in the days before open source was the big thing, and now Sun is not so loved. In the aftermath of the hullaballoo, Java remains a slug of a language implementation.

Meanwhile, I can whip up apps in Python in no time and they run far faster and with less nonsense and hassle. Slower than C? Yes. Better for rapid prototyping and quick problem solving on the fly? Yes. Best language I know to bridge structured and object oriented paradigms? Yes.

If I haven't already bought this book, and I may have and just not remember given the stacks of them on my various desks, I will then do so and give a copy to my godson who is just learning about computers. The archaic school system might still be teaching LOGO and I want him to see something that he can actually use.

Re:Python is SLOW (1)

DrSkwid (118965) | more than 7 years ago | (#16739841)

java is quite competitive these days re: execution speed.

Do keep up old chap.

Re:Python is SLOW (1, Insightful)

Anonymous Coward | more than 7 years ago | (#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 (1)

grrrgrrr (945173) | more than 7 years ago | (#16739919)

Java has a very very fast and advanced virtual machine much much faster than python's. The advantage python has is that a lot of the libraries are implemented in c where java implements most in java itself. A lot of what is already implemented in the operating system java implements it again.That makes also the startup time of java very slow (it is like booting up a new computer). But simply saying java is slower than python is not true at all.

Re:Python is SLOW (5, Interesting)

Ashcrow (469400) | more than 7 years ago | (#16741245)

It really depends on what your doing with it. If you come from the Java world and write Python code like you would Java code it is quite slow.

Also, keep in mind Python does not use a virtual machine at all in the same way Java does -- which means it is somewhat like comparing apples to oranges.

I was a full time J2EE engineer for a while and a recent convert to Python for general programming. The things I noticed are:

- Java is great for large teams of programmers working together across the globe but as good as Python for smaller groups in the same place.
- Python's web frameworks are amazingly fast and very powerful.
- Java is almost text book perfect when it comes to programming. Unlike most other languages kids can come out of university and not have to change hardly anything to get started in the real world of Java.
- It's very rare to see stock Tomcats or even stock JVM's meaning that most (commercial) Java apps send the entire 'Java OS' (VM) with their products.
- Java web apps are very slow on startup, but scale well after the startup time.
- Python has a better RORA system, though Java isn't to far behind.
- Java terminology is very confusing compared to Pythons esp. since it is generally termed by marketers (Java2 is Java1.4 and then we hit Java 5 which is Java1.5 ...)

Here is how it seems companies leverage the languages ....

1. Java
Manager's reason for Java: "I have a large IT infrastructure and want to do enterprise applications with teams across the globe."
Engineer Translation for Java: "I have an over all large group of engineers and want to make an application designed by the business with at least some of the team out sourced."

2. Python
Manager's reason for Python: "I have a small IT budget and want to agile and business reactive application development."
Engineer Translation for Python "I don't have a budget to get more engineers and the requirements state that we need to be able to change and update the application on the business whim."

In scenario number 1 it is a growing company who wants to hire lots of new engineers so the plus side of using Java is:

1. Just about every engineer (good or bad) knows it
2. It enforces C++ like development cycles
3. If done right, the objects are reusable and simple for an architect to understand
4. You can hire fresh outs

In scenario number 2 it's a growing company who is not investing more money in the IT department but expects better results for the buck put into it. The plus side of Python would be:

1. It's a RAAG language (read at a glance) which means you can skim through the code quite quickly without needing tracers or debuggers.
2. By design each engineer is a mini architect
3. If done right, the objects are reusable and simple for engineers to grasp quickly
4. The quality of engineers you get tend to be quite high since most Python engineers are converts from other languages with X years of experience in the field. (though it also means you can't hire as quickly).

Bottom line there is no right or wrong answer as to which is better or faster. Python is faster in some cases and Java is faster in others and it largely depends on how you run your business and the money that you want to spend in IT as to which one would help your company.

Re:Python is SLOW (1)

masklinn (823351) | more than 7 years ago | (#16741813)

Java is great for large teams of programmers working together across the globe but as good as Python for smaller groups in the same place.

This is awfully debatable. The explicit static typing and ease of static analysis makes error-checking much easier in Java, which makes for much easier QA if you don't like testing. Java also have very good IDEs, which it doesn't deserve. But the verboseness of Java and it's lack of many (syntactic or other) niceness such as first-class-object functions, tuple-unpacking, litteral syntax for common containers (lists, hashes, ...), ... make it much slower to use as a developer. It also requires the users (of the language) to think at a much lower level, akin to C versus Java. If "smaller groups" have a good knowledge of the language, Java just can't beat Python.

Python's web frameworks are amazingly fast and very powerful.

They're not that fast (even though most of them are fairly fast). And Python has the "more frameworks than built-in types" issue making it a pain to pick a framework.

Java is almost text book perfect when it comes to programming.

Are you joking? Java's a textbook piece of shit when it comes to programming. Python is not *that* much better by the way. If you want "textbook perfect", go check functional languages. Or Smalltalk if you're into OO.

Unlike most other languages kids can come out of university and not have to change hardly anything to get started in the real world of Java.

The fact that most unis and schools now teach "computer science" in Java may have something to do with that one...

Re:Python is SLOW (1)

nuzak (959558) | more than 7 years ago | (#16742139)

> - Python's web frameworks are amazingly fast and very powerful.

Python has a pile of MVC frameworks with 99% overlapping functionality but little else. Show me Python's answer to JSF, Tapestry, or Wicket.

Re:Python is SLOW (0)

Anonymous Coward | more than 7 years ago | (#16740311)

Java is far slower

1999 called, they want their comment back!
Sorry, but Java is much faster than Python here in 2006.

Re:Python is SLOW (0)

Anonymous Coward | more than 7 years ago | (#16739649)

I really, really wanted to like Python. I even got over the ridiculous whitespace issue. But the slowness issue was definitely what killed Python for me. It is just god-awful slow. For equivalent tasks, my Java code is faster than Python. My Tcl code is faster than Python. Even my Ruby code is faster than Python. Until Python gets a lot faster, I won't be using it for anything. Speed isn't always the most important factor, but with Python the slowness is just too much to ignore.

Re:Python is SLOW (1)

zapadoo (807744) | more than 7 years ago | (#16740071)

Ruby faster than Python? Hogwash.

Ruby is easily, measurably, slower than Python - its a big topic of discussion in the Ruby community and the subject of numerous projects to address.

Re:Python is SLOW (4, Informative)

kpharmer (452893) | more than 7 years ago | (#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.

Re:Python is SLOW (1)

masklinn (823351) | more than 7 years ago | (#16741941)

Even my Ruby code is faster than Python.

That simple stupidity just made everyone who knows anything about Ruby and Python dismiss your post as utter nutjobbery.

Java is indeed faster than Python by a large margin (unless the runtimes are short, in which case the sheer monstruosity of the JVM's startup time kills Java's perfs).

TCL compares very favourably to Python, even though it's mostly slightly slower, unless you're using Regexp (the Tcl regex engine is just wicked fast).

But Ruby on the other hand, is one of the slowest languages available today. The current baseline implementation is a piece of crap, it's wasteful, it doesn't have any optimization, it's more or less the slowest and worst way to implement an interpreted language. Even though Ruby is a quite nice language, speed is definitely not it's forte.

The only way for Python to be slower than Ruby would be to code Ruby in Ruby while you're coding Java in Python (using Java idioms and techniques while producing Python code, which is a bad idea).

Re:Python is SLOW (1)

sowth (748135) | more than 7 years ago | (#16742767)

This is why there is so much interest in a Python compilier--compiliers are much faster than interpeters. There are some starting projects--such as psycho and Python 2 C Module Generator [sourceforge.net]

Java and TCL have certainly had many more years and manpower to optimize thier implementations. I don't know much about Ruby. I'm sure in a few years, Python will improve too.

Re:Python is SLOW (2, Informative)

jamwt (220439) | more than 7 years ago | (#16739711)

...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!

Re:Python is SLOW (2, Insightful)

MtHuurne (602934) | more than 7 years ago | (#16740233)

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 (0)

Anonymous Coward | more than 7 years ago | (#16740237)

"Python is SLOW"

Shrug. The "official" python implementation is indeed slow.. compared to say, C++ or Java. But, is it too slow for some particular application? That's what matters, and in many cases it is not too slow.

I've done some work on a spim (IM spam) filter for AIM - pyboticide. It was written entirely in python, and was essentially a stripped down OSCAR server proxy. It was certainly fast enough for that, and since it was written in python it was very easy to work with the source code. :)

An application only needs to be as fast as it needs to be - no faster.

Ruby is SLOWER (2, Funny)

sbrown123 (229895) | more than 7 years ago | (#16740553)

Somebody was going to say that too.

Re:Python is SLOW - but 3 times faster than C (0)

Anonymous Coward | more than 7 years ago | (#16742027)

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.

Python is easy to learn (1)

ChaosWeevil (1004221) | more than 7 years ago | (#16739141)

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).

python.org (1)

chroot_james (833654) | more than 7 years ago | (#16739225)

has documentation too...

Got and Older Edition (1)

Azarael (896715) | more than 7 years ago | (#16739297)

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.

Nice book report (1)

nuzak (959558) | more than 7 years ago | (#16739319)

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.

Re:Nice book report (1)

Osty (16825) | more than 7 years ago | (#16740243)

It's no wonder I skip straight to the comments -- these reviews are just about the most content-free section of slashdot.

I could almost accept the contentless-ness of the "review" if it was at least readable. "Book report" is right, as this reads like it was written by a 4th grader. It's full of run-on sentences, sentence fragments, overly-repeated phrasing ("This book", "The book") and sentence structure, convoluted paragraphs covering multiple unrelated topics, minor spelling and punctuation errors, etc.

As book reports go, I'd expect this one to get a C+ or B- depending on whether we're talking about 3rd or 4th grade. As a semi-professional book review by a supposedly-educated adult, this gets an F.

My favorite Python joke (1)

DysenteryInTheRanks (902824) | more than 7 years ago | (#16739339)

Q: How many Python programmers does it take to screw in a lightbulb?

A: That joke's not funny.

portable gui (2, Interesting)

Speare (84249) | more than 7 years ago | (#16739349)

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.

Re:portable gui (4, Informative)

jamwt (220439) | more than 7 years ago | (#16739517)

How about wxPython? [wxpython.org] Or, if you prefer, PyQT [riverbankcomputing.co.uk] ? Both excellent.

Re:portable gui (0)

Anonymous Coward | more than 7 years ago | (#16739537)

FWIW, it's fairly easy to upgrade Python to 2.4 or 2.5 on OS X using DarwinPorts or Fink.

Re:portable gui (1)

izomiac (815208) | more than 7 years ago | (#16739541)

WxPerl [sourceforge.net] looks fairly native to me. I tried it out a few years ago, but haven't stuck with it since I switched to an OS that it doesn't support.

Re:portable gui (3, Informative)

Electrum (94638) | more than 7 years ago | (#16739575)

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 (0)

Anonymous Coward | more than 7 years ago | (#16739633)

I'm sure you've come across PyQt [riverbankcomputing.co.uk] so I guess it doesn't fit your needs either, but I thought I'd mention it anyway. Qt is a great GUI toolkit and has the native look and feel of the platforms it runs on.

Re:portable gui (3, Informative)

vivek7006 (585218) | more than 7 years ago | (#16739635)

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:portable gui (1)

hachete (473378) | more than 7 years ago | (#16740599)

wxWidgets comes with a binding for quite a few languages, and support for a lot of platforms, including PDAs. wxPython is pretty cool.

Re:portable gui (1)

ZeroTrace (594778) | more than 7 years ago | (#16739663)

A mac port of pygame is available here: http://pythonmac.org/packages/py24-fat/ [pythonmac.org]
It uses some form of wrapper program for the SDL surface so it doesn't need X11... Take a look.

Re:portable gui (0, Offtopic)

Jerf (17166) | more than 7 years ago | (#16739717)

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.
What you're probably looking for there is wxWidgets [wxwidgets.org] , which is a sophisticated native wrapper around each of those and has binding for Python, Perl, and the usual motley crew, including .Net and to some extent Java (I think).

It has XRC [wx4j.org] files, which I think is how GUI designers tie into wxWidgets, covering that, too. I'm in the GUI builders are evil [java.net] camp, so I don't know much more about that.

Tk sucks, but the general trend seems to have been away from shipping a standard GUI toolkit. There's just too many choices ranging from good to excellent to choose one. (And note this is not a problem specific to Python, it's true for all of the mainstream languages. How do you choose between GTK/QT/WinForms/Carbon/wxWidgets, plus a couple of other credible contenders, plus perhaps whatever your local GUI system is if you're on an exotic system, etc. They've all got obvious platform compatibility and licensing tradeoffs, and a whole slew of much more subtle quality and capability tradeoffs. It's really not possible at the current time to mandate one choice. I'd rather see Tk just come out than try to standardize on something els.)

Re:portable gui (1)

newt0311 (973957) | more than 7 years ago | (#16743219)

PyGTK. GTK has ben ported native over to windows and PyGTK is much easier (IMHO) to code in than PyQT or especially tk.

BN is overpriced (2, Informative)

Electrum (94638) | more than 7 years ago | (#16739455)

Save some money:

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

You're a bunch of brainless faggots (1)

lennyhell (869433) | more than 7 years ago | (#16739573)

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.

Re:You're a bunch of brainless faggots (0)

Anonymous Coward | more than 7 years ago | (#16739867)

You really are a literary genius, have you thought about writing childrens novels?

Re:You're a bunch of brainless faggots (1)

lennyhell (869433) | more than 7 years ago | (#16740067)

I write all the GNAA Press Releases, you insensitive clod.

Arg (0)

Anonymous Coward | more than 7 years ago | (#16739589)

Python and its retarded syntax, what the hell where they thinking?

Re:Arg (0)

Anonymous Coward | more than 7 years ago | (#16741053)

Absolutely nothing!

use the O'Reilly Pocket Reference first (1)

LM741N (258038) | more than 7 years ago | (#16740085)

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)

Re:use the O'Reilly Pocket Reference first (1)

lpointal (953132) | more than 7 years ago | (#16742013)


If you've got a printer, you can also use my Quick Reference Card (PQRC)
at http://www.limsi.fr/Individu/pointal/python/pqrc/ [limsi.fr]

Re:use the O'Reilly Pocket Reference first (1)

LM741N (258038) | more than 7 years ago | (#16742525)

That looks pretty cool. I should also point out that Python comes with excellent documentation that by itself is more than enough to learn the language. I just like little portable books rather than online docs or printed paper.

Python Tutorial (1)

delsvr (687275) | more than 7 years ago | (#16740135)

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./ [www.python.org]

python book du jour and speed (0)

Anonymous Coward | more than 7 years ago | (#16740291)

The python book that percolated to the top of my heap is "Test Processing in Python" by David Mertz. Me being a working programmer for 20+ years starting with K&R C, C++ in '89, Linux 0.99, etc.


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.

Re:python book du jour and speed (0)

Anonymous Coward | more than 7 years ago | (#16741019)

The python book that percolated to the top of my heap is "Test Processing in Python"

What kind of tests do you process?

Psyco 1.5 speeds up python 2.4.x to about 50% of java

Well, 50% of Java is certainly a new standard for speed...

Chapter 13?!?!? (1)

scherrey (13000) | more than 7 years ago | (#16740509)

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...

The book seems mighty fine, but the review? (0)

Anonymous Coward | more than 7 years ago | (#16741529)

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.

System requirements for Python web dev seem high (1)

walterbyrd (182728) | more than 7 years ago | (#16742199)

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.

Re:System requirements for Python web dev seem hig (1)

gabor1023 (911057) | more than 7 years ago | (#16743019)

django and turbogears both run fine on apache1 too. or on lighttpd... or basically anywhere where there is fastcgi or scgi:

http://code.djangoproject.com/wiki/ServerArrangeme nts [djangoproject.com]

http://docs.turbogears.org/1.0#deployment [turbogears.org]

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)

WTH?! (0, Troll)

sofar (317980) | more than 7 years ago | (#16742245)

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/ [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.

Re:WTH?! (0)

Anonymous Coward | more than 7 years ago | (#16742987)

> umm hell, python is notoriously known for bad coders, writing broken applications based on underdeveloped and unmature modules, breaking forward compatibility.

Hmmm, been writing python for six years with some of the best engineers I've worked with over the past 25.

Haven't had any problems with compatibility, nor have i found that python attracted poor programmers. Quite the opposite: the poorest programmers are happily chugging along in cobol, perl and java from my experience.

Sounds like you spend your time with bad programmers and bad code.
Load More Comments
Slashdot Account

Need an Account?

Forgot your password?

Don't worry, we never post anything without your permission.

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>
Create a Slashdot Account

Loading...