Open Question - I'm a complete novice in programming so please bear with me...Is python equivalent to C, C++ and java combined?

Chris Angelico rosuav at gmail.com
Sun Jan 12 00:58:45 EST 2014


On Sun, Jan 12, 2014 at 4:08 PM, Steve Hayes <hayesstw at telkomsa.net> wrote:
> So the question is, which kinds of programs is Python best for?
>
> I'm a novice at it, so it's a question that concerns me. From what I've heard
> and read, it seems to be a fairly good general-purpose language, and it seems
> to be most used for writing web applications (though that is not something I
> am particularly interested in).

Python puts heavy focus on code readability (which also means it's
easy to write). So it gains you hugely for small scripts, less so for
things that need to run millions of times a second.

Python has a variety of libraries that make it well suited to internet
applications (as server or as client).

Python, especially as of version 3.3, is superb at handling
internationalization, Unicode, and related messes - you can sort out
files of different encodings and rewrite them in something consistent
(eg UTF-8). It may seem a bit harder at first, as you're forced to
think about the meaning of bytes and what's text and so on, but it's
worth it.

Python is NOT good at massively parallel numerical calculations.... on
its own. But there are libraries that can do that sort of thing for
you (NumPy, SciPy); I've no idea how good they are because I neither
use them nor write code that would benefit from them, but they're
extremely popular and well-used.

As a general rule, if your program is likely to spend most of its time
waiting (for the disk, the network, the user, etc), then Python is
probably at least as good a choice as C, Java, or any other language,
and the question will come down to library support and such.

Python is also an excellent "super pocket calculator". The
reasonably-compact notation for aggregate operations (list
comprehensions and such) lets you work with a functional programming
style, and you can use step-by-step imperative programming in the same
way. Want to calculate the average result of rolling six six-sided
dice, and discarding any results below 14? Try this:

http://www.kickstarter.com/projects/916188323/doublesix-dice-roll-better/comments?cursor=5623335#comment-5623334

(BTW, is there no better notation than six nested for/range for doing
6d6? I couldn't think of one off-hand, but it didn't really much
matter anyway.)

The incremental execution of Python's interactive interpreter (REPL)
is extremely convenient for this. I personally like using IDLE for
this, as (unlike command-line Python) it will recall and edit an
entire suite, rather than one line at a time. Extremely handy.

ChrisA



More information about the Python-list mailing list