Domain: python.org
Stories and comments across the archive that link to python.org.
Comments · 1,513
-
Re:Faster language?
When you have a language like Python, which is defined by a single (very slow) implementation
Which of C Python, PyPy, Jython, or IronPython is the only implementation?
-
Re:Why not Python? (and other cliches)
What's the matter, bored with arguing why emacs is better than vi or vice versa? See August 1999 on python-list's archives for your exact question. If only you folks could have waited one more year, this could have been a commemoration of the 10 year anniversary. Actually, if you do go look up that thread, read this one instead, it's not nearly so stupid, just the opposite: Tom Christiansen compares Perl and Python
-
Re:Ockham's Razor tells me....Continuing...
Let's just look at how ugly Perl 6 is planning to be.
sub somefunction($a, $b,
:$c, :$d, *@e) {...}
somefunction(1, 2, :d<3>, 4, 5, 6); # $a=1, $b=2, $d=3, @e=(4,5,6)
somefunction(:b, :a<1>); # $a=1, $b=2Can anyone think of a better non-ugly syntax for that? Well in Python you can use arrays and dictionaries
... so it's just somefunction(key=value, key2=value2) or if you want to store your function parameters in an array beforehand you'd just writeparams = {key:value, key2:value2}
somefunction(*params)...and the params variable would be unpacked.
You'd really have to struggle to think of a more inelegant syntax than that of Perl 5 or 6, although there are strong bets on Perl 7. what about exploding dictionaries from Python? You simply put *
-
Re:Yes, but with a twist
The difference, I see, is that Land was the chief guy people expected all tech advances to come; once Land left there wasn't any one person to keep their eye on the industry. Jobs, however, is not the tech guy; he has a *lot* of good people who are clearly making great stuff, only to be held in check by Jobs until he's satisfied they "have a product".
This reminds me of the "What if Guido van Rossum was hit by a bus" discussion on the Python list. And also the "What if Linus died" thing. With Linus (Guido) as the ``Dictator'' of Linux Kernel (Python) because of their talent in technology AND their vision AND their role in the community as The Irreplaceable who has final say on everything. I believe good programmers as Linus and Guido are not scarce, but if they as ultimate leaders of large, loosely organized communities, were no longer there, what will happen to the community? Can they adept to the new situation fast enough? Or will it end up like a ``warring state'' situation and being divided-and-conquered by the Extend-Embrace-Extinguish tactic?
-
Re:Never heard of Django before, now it's everwher
Just to follow up: Python has two flavors of tests -- unittest, which was originally the PyUnit software you've already been pointed to, and doctest which lets you write interactive examples -- and Django's test framework has baked-in support for both of them, along with extension points to plug in your own system if you prefer. There's also a dummy HTTP client which can send requests and inspect the responses being sent back (including verifying data-processing from the backend), and a co-worker of mine has released some software which generates a test suite from a live browser session to ease creation of your tests.
Personally, I've always felt that Python's doctest system is one of the greatest things since sliced bread; for example, it lets us produce a single document which in one context can be processed as API documentation but, in another, is executable as a unit test suite for the features it's documenting.
-
Re:Never heard of Django before, now it's everwher
Just to follow up: Python has two flavors of tests -- unittest, which was originally the PyUnit software you've already been pointed to, and doctest which lets you write interactive examples -- and Django's test framework has baked-in support for both of them, along with extension points to plug in your own system if you prefer. There's also a dummy HTTP client which can send requests and inspect the responses being sent back (including verifying data-processing from the backend), and a co-worker of mine has released some software which generates a test suite from a live browser session to ease creation of your tests.
Personally, I've always felt that Python's doctest system is one of the greatest things since sliced bread; for example, it lets us produce a single document which in one context can be processed as API documentation but, in another, is executable as a unit test suite for the features it's documenting.
-
Re:Never heard of Django before, now it's everwher
The Google App Engine already has the Django libraries available.
Have a little care, there. The GAE caused quite a stir in the Django community, because it is only a partial implementation of the database interface that Django normally uses. It is backed by BigTable, which is blazing fast, but not a full blown relational database. If that works for you, go for it - it looks like a sweet platform for certain kinds of projects.
As for your question about Java->Python, I'm a former C++ convert myself, but I can help a little here. For some 'compile time' checking, look at PyLint It may check too much for you, but you can turn off the stuff you don't want.
As for unit testing, PyUnit is a pretty straight port of JUnit, so that should look familiar. However, I actually find nose to be a little better. It has many of the same capabilities, but with less boilerplate needed, and it integrates well with any existing PyUnit or DocTest tests.
-
Re:Python 3.0 in months, bad time for teaching Pyt
This is the wrong time to pick Python for teaching. Python 3.0 is coming out in months. It's going to be incompatible with all the 2.x versions. There's going to be major changes that effect everything all the way down to "Hello World."
That sounds like a big confusing mess to deal with explaining to a student.
Link to python 3.0 info... http://www.python.org/download/releases/3.0/
Python 3.0 will change far less than most libraries' APIs do between major version releases. If this is really such a deal breaker for you, trust me, noone in the Python community will miss you.
Hell, noone in the wider programming community will etc.
This isn't pointless change just to give the Python-detractors something to crow about. (God knows there are times I'd wish Python 3.0 had kept print as a keyword just so people like you would STFU about it.) When did improvement become so damn anathematic to people in the IT industry?
It's change or die.
-
Re:No ShortCuts !!!Boy do I feel stupid and misinformed. I must have, at some point in the past, taken a tutorial's reccommendation as gospel truth.
From http://docs.python.org/ref/indentation.html we haveAt the beginning of each logical line, the line's indentation level is compared to the top of the stack. If it is equal, nothing happens. If it is larger, it is pushed on the stack, and one INDENT token is generated. If it is smaller, it must be one of the numbers occurring on the stack; all numbers on the stack that are larger are popped off, and for each number popped off a DEDENT token is generated.
I sit corrected, and now have to look at learning python next year instead of Tcl.
-
Python 3.0 in months, bad time for teaching Python
This is the wrong time to pick Python for teaching. Python 3.0 is coming out in months. It's going to be incompatible with all the 2.x versions. There's going to be major changes that effect everything all the way down to "Hello World."
That sounds like a big confusing mess to deal with explaining to a student.
Link to python 3.0 info...
http://www.python.org/download/releases/3.0/ -
I like the python (and C) style guides PEP
See these:
http://www.python.org/dev/peps/pep-0007/ C Style Guide
http://www.python.org/dev/peps/pep-0008/ Python Style Guide
http://www.python.org/dev/peps/pep-0020/ " Readability counts."I think python is the one language where "good code==natural code". Can't hurt to read the thoughts behind this
... -
I like the python (and C) style guides PEP
See these:
http://www.python.org/dev/peps/pep-0007/ C Style Guide
http://www.python.org/dev/peps/pep-0008/ Python Style Guide
http://www.python.org/dev/peps/pep-0020/ " Readability counts."I think python is the one language where "good code==natural code". Can't hurt to read the thoughts behind this
... -
I like the python (and C) style guides PEP
See these:
http://www.python.org/dev/peps/pep-0007/ C Style Guide
http://www.python.org/dev/peps/pep-0008/ Python Style Guide
http://www.python.org/dev/peps/pep-0020/ " Readability counts."I think python is the one language where "good code==natural code". Can't hurt to read the thoughts behind this
... -
Python ODBC
What can an app written in VBScript+Access do that an app written in Python+SQLite can't?
Open existing Access Databases.
Apparently, someone got Python to run queries on Access
.mdb files through ODBC. -
Re:MOD PARENT UPPython has the Global Interpreter Lock, which means even though there are threads, they don't execute concurrently. Too bad if your server has several processors / cores.
Love Python; hate GIL. Trust me, I know exactly what you mean.
That said, there are quite a few multi-processing packages for Python (disclaimer: two of the ones under SMP are mine, so I'm kind of biased toward the idea). Also, Python 2.6 will ship with a standard multiprocessing module that's very similar to it's multithreading counterpart and should be an easy migration.
Multithreading is cool, but there are other ways to skin that cat.
-
Re:MOD PARENT UPPython has the Global Interpreter Lock, which means even though there are threads, they don't execute concurrently. Too bad if your server has several processors / cores.
Love Python; hate GIL. Trust me, I know exactly what you mean.
That said, there are quite a few multi-processing packages for Python (disclaimer: two of the ones under SMP are mine, so I'm kind of biased toward the idea). Also, Python 2.6 will ship with a standard multiprocessing module that's very similar to it's multithreading counterpart and should be an easy migration.
Multithreading is cool, but there are other ways to skin that cat.
-
Re:Goes to show ...
So, um, how's jPHP and Jython coming along? Would you deploy a real life application on Jython?
So, um, how's jPHP and Jython coming along? Would you deploy a real life application on Jython?
Go team. Rah! Rah! Rah! YEAH!!!!But I have two questions:
1. What does the relative merit of Jython versus Jruby have to do with the price of tea in China? Are you moving your apps from the buggy MRI to JRuby this week to avoid these security holes?
2. What evidence do you have that Jruby is more appropriate for "real life applications" than Jython? I know people who have deployed real life applications on Jython since before the first checkin of JRuby. For example, Websphere ships with Jython.
http://wiki.python.org/jython/JythonUsers
Ruby has some real advantages over Python. But if you don't know them, don't just make stuff up.
-
Re:My feeds
Now that I'm working in academia researching functional programming languages I read feeds like Lambda the Ultimate, comp.lang.functional, PLNews, Topix Programming Languages, Planet Python and Planet Haskell.
-
Re:Language Compatibility vs. Class Libraries
> I wish that someone would create a non-bloat version of the Java class libraries. Do an analysis
> of important use cases, redesigned the class libraries to be much less "fluffy"
Somebody did just this already. -
Atomic replacing under all file systems/You don't need any extra kernel support for that. You just write the new version under a temporary name, and then atomically rename it over the old file. This is true if your file system supports atomic replacing. Under some file systems, renaming file A over file B will cause file A to replace file B. Under other file systems, renaming file A over file B will return a failure code or throw an exception; an application is expected to delete file B, warn the user, and then retry moving file A. See the documentation for Python os.rename .
-
ECMAScript 4
ECMAScript 4 will be a modern language in all senses of the word. It will support optional type annotations, destructuring assignment, generators, convenient inheritance, and all the other trappings of a modern language.
With ECMAScript 4, the advantages of running anything other than Javascript fade away: you still have all your Ruby/Python/Lisp features, just spelled differently.
And from the browser point of view: would you rather create a generic scripting framework or add one language and be done forever?
Also, instead of trying to compile languages to MSIL, why not just write a source-to-source translator to Javascript? Isn't that what some people do to Java these days? -
Re:Operation and Cost?
These problems go to Windows to its core. How do we change the Registry in text format so that we can guarantee that we do not corrupt it? I'm sure there's a commandline regedit somewhere, but I'd like to edit it as flat files ala
Meet the _winreg Python module. /etc.I'd like to use a Microsoft system that does not require graphical support. Where's a rich commandline for those that need no graphics (samba server, calendar/mail server..)?
Windows 2008 Server has this, I believe.I'd like a full update of nearly every program at once.
win-get is like an apt-get for Windows.Windows has file locking. Linux doesnt.
Um, that's just plain wrong. You're obviously not a programmer or a sysadmin.I can save a MP3 in linux and play it at the same time. I can also delete it WHILE playing and nothing bad happens (until I hit the beginning again).
That's a function of how the applications are written and has nothing to do with the OS whatsoever.There's tons of things here and there that will lessen the usability of ported BASH and python on Windows.
I won't disagree about bash, 'cause you're right, but Python works pretty well on Windows. Gotta give kudos to PSF on that one.
Don't get me wrong. I run Ubuntu almost execlusively at home. But my knowledge of Windows is pretty deep as well, and while I don't like Windows, I know how to get by on Windows out of sheer necessity. -
Re:Operation and Cost?
One would need a full scripting language, like bash, to do such.
Not that I'm trying to argue for the Windows crowd, mind you, but you have two options:- Cygwin, which includes bash and it won't cost you a single pennny.
- Python, which can do almost anything you can imagine. It also runs on Windows and will cost you $0.
-
Re:Off the top of my head?I'm not sure if you're referring to Python, but just in case:
Andy reasonably experienced programmer can pick up basic Python in two days or so.
A friend of mine switched from Perl to Python and was writing IRC bots a day later.
ESR describes how he was doing metaclass programming in less than a week:To say I was astonished would have been positively wallowing in understatement. It's remarkable enough when implementations of simple techniques work exactly as expected the first time; but my first metaclass hack in a new language, six days from a cold standing start? Even if we stipulate that I am a fairly talented hacker, this is an amazing testament to Python's clarity and elegance of design.
http://www.python.org/about/success/esr/
And since syntax/readability is to a large extend guaranteed by the whitespace in Python, it'll only become easier to dive into existing code for someone else. -
Re:Off the top of my head?
I'm mainly a C hacker, but I don't get why people would prefer Python over Java.
I think it's the whole "Python fits in your brain" thing. Or as ESR has once put it: Python is the language that comes the least between you and the problem you're trying to solve and I completely agree with that.
Speaking for my self, just as an example and not trying to start a X vs Y war:
I have to lookup how to open a file for input in Java every single time.. in Python my first guess is usually correct and opening files is just a matter of filehandle = open("file.txt", "r")
I do not like the hoops through which Java is trying to make me jump at all..
http://www.javacoffeebreak.com/java103/java103.htmlThat was my first surprise. My second came a couple of hours into the project, when I noticed (allowing for pauses needed to look up new features in Programming Python) I was generating working code nearly as fast as I could type. When I realized this, I was quite startled. An important measure of effort in coding is the frequency with which you write something that doesn't actually match your mental representation of the problem, and have to backtrack on realizing that what you just typed won't actually tell the language to do what you're thinking. An important measure of good language design is how rapidly the percentage of missteps of this kind falls as you gain experience with the language.
Source and a nice read with the subject "Why Python?":
http://www.python.org/about/success/esr/
My personal experience are summed up with the lines:
- Easy to write and maintain.
- A very fast development time compared to many other languages.. and for most applications I work on, my time is more precious than that of a CPU.
And it's not just for me... my customers love it and are amazed how frequently I can come with a functional prototype or a completely working application. If the app. runs in 2 or in 5 seconds is far less important for what I'm doing. (Yes, low level, high performance computing is a different story)
- Powerful and flexible enough to do most things I want, scales from small to big apps, from functional programming to OO programming; excellent modules.
- Because the language is almost pseudo code like, I notice that I have noticeably less bugs in my code. Not just just the moment after writing it, but in the entire lifespan of the application I have less maintenance than I think any other language. -
Re:Ruby and Python making Java die? Ha!Python and Ruby... are SLOW Of course, that's a feature of a given implementation rather than a language, but it is a valid concern today, moreso than it is with Java. But if we brush that aside and ask which language works better for large projects and is easiest to use... well, I'll leave that up to you. I think that with new compilers with better room for optimisation (eg, Pypy), this might not be a problem for much longer. which automatically disqualifies them in a lot of areas (like high-performance computing). Well, if you're talking serious HPC, I guess you're right. I don't know of any number crunchers running Ruby. On the flipside, it doesn't seem to be an area that Java is too big in either. Cray, for example, do not ship an auto-distributing JVM or Java compiler with their environments, last I checked. Also, Python interpreter is STILL single-threaded. As most python programmers will tell you, this isn't as much of a problem as people make it out to be. Threading happens to be a pretty ordinary way of expressing parallelism. With the pyprocessing module that will come with 2.6/3.0, there will be a thread-like API for interacting with several python processes in the standard library, and some special objects to take care of data sharing.
Further, using threaded extensions (via the C-API or cython/pyrex) is often a great way to get the required parallelism, and where it belongs- in the code that needs to be carefully optimised C. Besides, JVM can serve as a platform for many languages. Absolutely true. Another example is Pypy :) -
Re:I don't really get the Java hate around heresee http://norvig.com/python-lisp.html section 10
the author looks like he is inexperienced, and unaware of the function "reduce", ... (along with map ...) Maybe you should send the author a note about map and reduce. As director of Research at Google, he's probably in a position to influence some of their programmers to make use of map and reduce. -
Re:Off the top of my head?
Well, it's got a better object model than Java, and it's a lot faster to code with. Java just isn't appropriate in every situation.
Python also plays well with C, so it's often used in concert with C for interfaces, etc. -
If "innovation" means "open source"...
Just as one data point: here at SnapLogic, our product is open source. Myself and the other engineers are paid to work on GPLed software full time.
It's not just our core product. I'm responsible for the QA infrastructure, and in that role I've been able to contribute code to other projects we use: Django, Trac (one two three), Figleaf, and Buildbot (one two three four).
That's just what I have done personally, not to mention the other engineers. And it's not just something we do on the side - the company's upper management actively encourages us to contribute code back.
So in our particular case, just day to day operations intrisically seems to benefit the open source commmunity as a side effect. At least from my perspective (and by the way, I don't speak for SnapLogic). If something dramatic happened and we had to shut down, that would obviously stop.
[Holy cow, I'm being paid to write free software in my favorite language. Pinch me.]
-
Re:Python comes with SQLite1) My example was done to show how quick and easy it would be to set up and populate a table in Python.
2) He's explicitly mentioned several times that this is for his own private non-web use. But when doing so using good practices is so amazingly easy, why do even demo examples in a different way? It's not like you're using Java or C#; the right way doesn't need to be bureaucratic...
BTW, I checked the python docs and I'm happy to report that they strongly promote doing it the right way too. Thus you can do it right for almost the same amount of code:
mydb.execute("insert into contacts values(?,?,?)", ("Spooky", "Monster", "spook@spammity.spam"))
(I could comment on the merits of named versus positional parameters, but that's getting too close to language flaming. Off topic for here, and uninformative in any case.) 3) Your fly is open. Now you're just making yourself look like a silly kid. -
Re:Python comes with SQLiteActually, the Python SQLite adapter supports the standard Python DB API (PEP 249), and so you can just follow its recommendations (which includes using placeholders).
Yes and no. While it's DBAPI 2.0 compliant, it only supports the "qmark" paramstyle:
>>> sqlite3.paramstyle
'qmark'(Python 2.5.2 on FreeBSD 7.) The "named" paramstyle looks an awful lot like dkf's Tcl example. My favorite is "pyformat", such as in my PostgreSQL example, but alas sqlite3 was telling the truth above when it claimed not to support it:
>>> mydb.execute("insert into contacts values(%(first)s, %(last)s, %(email)s)", {'first':'Spooky','last':'Monster','email':'spook@spammity.spam'})
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
sqlite3.OperationalError: near "%": syntax error"qmark"-style parameters are just fine, though:
>>> mydb.execute("insert into contacts values(?, ?, ?)", ('Spooky','Monster','spook@spammity.spam'))
<sqlite3.Cursor object at 0x83206e0> -
Re:Python comes with SQLite
Actually, the Python SQLite adapter supports the standard Python DB API (PEP 249), and so you can just follow its recommendations (which includes using placeholders).
-
The actual request
The question seems slightly misguided, and the answers suggesting sqlite3 seem very good. However, if you want a literal answer, I would think that Python's csv module does what the poster requested: http://docs.python.org/lib/csv-examples.html. Well, if you're inclined in a different way, you could use Text:CSV: http://www.cpan.org/modules/by-module/Text/Text-CSV-0.01.readme
-
Re:Non free software and offshoring are evil.
... But they might be aided by Python.
-
Re:Doing things the slow way
*sigh* Please learn to understand computers. See this page: http://docs.python.org/tut/node16.html -- it seemed pretty good for explaining the basics.
8.12 = 8 + 0/2 + 0/4 + 0/8 + 1/16 + 1/32 + ... the list goes on. The problem exists because 0.12 cannot be represented as a sum of 1/2^i for i = 0 to 32 (or probably 64, or probably at all).
Further, this is why A GOOD ASSEMBLY COURSE should still be required in college. If you knew bitwise representations.. you'd know why you are NEVER supposed to take approx values and assume they're equal. As one person mentioned, rounding would give you the answer you wanted, but it's generally considered that two numbers are equal if the subtraction between them is 0.000000001 or so. After that, who cares?
As an interesting assignment, take values nearly 32 bits in size (start with 4 294 967 295 or so) and multiply them by numbers very close to zero -- 0.0000000001, for example. I'm sure you won't get anything very near zero.
And stop using int like that. You got rid of the 0.9999999999998234 extra that was attached to the number. Alternatively, knowing that 8 decimals is good-enough precision, another trick: int(double + 0.0000000001) should yield the true number.
perl -e 'print ((8.12 * 100) / 100);'
8.12
perl -e 'print (int(8.12 * 100 + 0.0000000001) / 100);'
8.12
perl -e 'print ( (8.12 * 100) - (int(8.12 * 100) + 1));'
-1.13686837721616e-13
Huh. accurate to 12 decimals. That's good enough for me, I guess. I suspect Java is no different. Basic math... for anything else, use Mathematica ;-)
-DrkShadow -
Re:Here's a good related question...
If you're on Mac/Linux, start coding in Python (http://www.python.org/). It's a simple, powerful, and flexible language which you can do a lot with. Basic Python program:
print "Hello, World!"
Yeah, that was the whole thing.
If you're on Windows, get Python anyway, or get the .Net framework runtime. I'm guessing you already know that .Net is Microsoft's answer to Java, and they're aggressively pushing it out to their whole software developer ecosystem. In fact Vista comes installed with the latest version. If you're on XP or earlier, you might already have a slightly earlier version of .Net installed. If you have it, then there'll be a C:\Windows\Microsoft.NET\Framework folder in your computer.
If you don't, you can get the latest version from Microsoft (http://www.microsoft.com/downloads/details.aspx?FamilyID=333325fd-ae52-4e35-b531-508d977d32a6&DisplayLang=en).
Once you have it, you can run all applications written in .Net, and you can write and run your own apps.
Here is where it gets interesting. To write programs for .Net, you can pick and choose from several languages. The framework itself comes with support for Visual Basic.NET, C#, JavaScript.NET, and C++. Since you mentioned coding cool stuff with Basic, let me mention that I used to write cool stuff (arguably :-) in QBasic as well back on Windows 98. But anyway, you can now write in Visual Basic, which has been upgraded to leverage all of .Net's power. Here's a basic (hah) graphical interface VB.NET program:
Imports System.Windows.Forms
Public Class Hello_World
Public Shared Sub Main()
MessageBox.Show("Hello, World!")
End Sub
End Class
To compile and run, type:
E:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\vbc test.vb .\test.exe
at a command prompt, where `test.vb' is the file wherein you have saved the source code.
Now, Microsoft offers free versions of its flagship Visual Studio developer products which make it very, very easy for you to code, especially nice graphical interfaces. And you can find those by doing a search for `visual studio' in the Microsoft website. But I will argue against it until you're moderately comfortable with a language and have in fact compiled and run some graphical programs which you coded yourself from top to bottom. The reason is that Visual Studio and its ilk automate so much of what you would do that if you start there, at best you'll never even learn of all those aspects of programming, and at worst you'll be thoroughly confused by what it does. This is what happened to me, for example, when I tried to dabble with writing MFC (Microsoft's previous attempt at making graphical interfaces easy) applications in Visual Studio 6 way back when.
Having said that, I've heard some really nice things about Borland Delphi, which is a more powerful version of Pascal which is said to be really fast as well. And it's a full-fledged development environment like Visual Studio, with support for code completion and all that. But, it's only available for Windows AFAIK. You can get it (free) at http://www.turboexplorer.com/, and check out some really awesome Flash videos they have up on http://www.turboexplorer.com/delphi/videos, where they take you step by step from no knowledge of programming to creating full-blown graphical apps with Delphi.
From what I know, the above are basically ways of creating rich-client GUI programs. Of course, there's a lot more to programming. If you don't want to download anything, just get Firefox and start hacking away in JavaScript/CSS and create some cool Web 2.0 apps in a single HTML file. -
Re:answers
One thing I've noticed in the few years I've been using Ubuntu is that each release quietly fixes at least one major annoyance -- drivers, multimedia, configuration, etc. Since Ubuntu 8.04 will be released on April 22, you might try a clean install of that and see if it fixes some of your problems. If not, then I agree with the other commenter who recommended Ubuntu Forums.
Programming: It sounds like you're interested in lower-level systems programming. A good book is "Linux Application Development" by Michael K. Johnson and Eric W. Troan. Most of the GNU and Gnome stuff is actually done in C, not C++, and GNU offers a thorough tutorial on C for the uninitiated. For C++, if you're committed to learning it, try "Effective C++" and "More Effective C++"; bookmark the standard library reference, and -- I notice you haven't listed any object-oriented languages -- read the "Case Study" section of the book "Design Patterns". Another language that you may find more enjoyable, and which occurs pretty regularly in GNU/Linux and especially Ubuntu, is Python.
IDEs: Eclipse is popular. Anjuta is very Gnome-ish and forms a nice collection of all the various programming utilities (autotools, gettext, glade, lint, indent, ...) that are worth getting to know. I actually just use GVim and the command-line tools -- if you're used to mainframes, you might be happy with that already. -
Re:General introductions to regex?
Everything I know about regular expressions came from the Python documentation. http://docs.python.org/lib/re-syntax.html
-
Major flaw in the build-process
This does not affect the users directly, but it is a major pain for integrators/porters. OO.o has a terrible habit of bundling all of the 3rd-party software packages, that it uses, into its own source tree. I'm talking about (probably missed some):
- agg
- bash
- bitstream-vera
- bsh
- bison
- boost
- curl
- db42
- dmake
- expat2
- freetype
- icu
- jpeg
- firefox (or some other Mozilla-based browser)
- libmspack
- libsndfile
- libtextcat
- libwpd
- libxslt
- neon
- nss
- nspr
- python
- sane-backends
- STLport
- unixODBC
- unzip
- vigra
- xmlsec1
- xt
- zip
- zlib
If they could, I'm certain, they would've bundled Java too, but — fortunately — Sun's license prohibits that... Now I realize, that this is done to offer "a single package" to those, who build it on their own, but nobody does. Everybody gets these from their OS' integrators. And the pain for us is enormous, because to force OO.o build to stop its silly ways is a serious undertaking. For some of the above packages there is --with-system-foo configure-flag, but not for all, and the default is to always use the bundled one, so support for the external ones bitrots quickly...
Most of the local builds don't bother and so end up wasting disk space and CPU-time rebuilding packages, which are external to OO.o. The end results are also bloated, duplicating stuff, that's already installed on the users' systems and without bug-fixes, which have already gone into each of the respective package since its most recent "bundling" into OO.o tarballs.
Download a source tarball and see for yourself... Something like: tar tjf OOo_OOG680_m9_source.tar.bz2 | grep 'z$'. No other software project does this on this scale and for good reasons — it is Just Wrong[TM]. OO.o better clean up their act in this respect...
-
Re:Python?
Python is a powerful language to know, but also very easy to learn and use. It is what many would call "executable pseudocode". In other words, when programmers discuss and draft code in pseudocode, it very often turns out to be a lot like Python. That's because Python syntax is simple, straightforward, and what people would expect.
I would agree very much that Python code is readable and maintainable.
More information on Python is available from the Python website. -
Python. Most universal PL out there.
I'm using PHP for my day-to-day work and deal a lot with Ruby fanboys, but I have to say that Python has a special place in my heart.
Here are the upsides (and some things that make Python exceptional) in my book:
1.) Very much like PHP and Perl, Python lacks the academic stench and has a general overall non-challance and n00by friendlyness to it. Things that *really* bug me about C and Java. And a smell that Ruby is gaining due to all the Java people brining their old bad habbits over to ruby.
2.) It's elegant and has a very neat and clean syntax, lacking the bizar and intimidating curly braces and semi-colons strewn all about in classics such as Java or JS. Or PHP for that matter.
3.) Indentation as block delimiter. The most ridiculed thing about Python (ridiculed by people who've never used Python) is acutally one of it's neatest features. Keeps code clean, minimal, human-readably and it's style in sync across many developers. Great for collaboration. And let's not forget that famous Donald Knuth quote: "We will perhaps eventually be writing only small modules which are identified by name as they are used to build larger ones, so that devices like indentation, rather than delimiters, might become feasible for expressing local structure in the source language." ... He said it best back in '74, nothing to add here.
4.) Python is used in serious non-trivial areas and applications in every field I can think of. Gaming, Multimedia/3D, Science, Large Scale HPC (Google f.i.), Embeded and, last but not least, sophisticated web applications. It apparently integrates very well as a scripting language, judging from the countless applications that use it as their choice of script and it also drives large non-trivial applications as core technology. (Googles Deployment Pipeline or, f.e. Blender)
5.) It's the foundation for the most sophisticated web kit to date: Zope. Zope is way ahead of anything in the Rails ballpark (or any other Web-FW), and it's only due to crappy project marketing on Zope's side that it didn't get as much attention in 2001 as Rails did since 2004. Until the MVC+SQL layering crowd catches up with Zope it will be another few years, until then it will remain the bar for any programmers who've ever come across it. (Like many PHP Framework & CMS developers I know)
6.) It's got a regular Webkit called 'Django' (drinking buddies of the Rails crew) which is quite popular and in itself makes me curious enough to want to pick up Python again.
Bottom line:
If you're looking to learn a new PL, give Python a try. And even if you despise that indentation thing I recommend you try coding in it for 20 minutes. You'll notice that it doesn't bother you at all, since programmers who are experienced enough to worry about that indent correctly all the time anyway. -
Re:Python?
The question was which programming language programmers should learn, and Python is one of the few reasonable answers I've seen in the comments.
If you program in Ruby, learn Python because it has been there before you, and you can often translate Python solutions into Ruby ones. Yes, I have personally translated Python code into Ruby back when Python 1.52 was the state of the art. Then Python improved so greatly that I dropped Ruby and canme back, mainly because of the wide variety of modules available for Python. After 7 years with Python, http://del.icio.us/tag/python continues to throw up surprisingly useful stuff.
If you program in Java, learn Python because you can begin to use it today http://www.jython.org/Project/index.html to reduce the number of lines of code that you have to write. The Jython code can access all of your Java classes so there is no need to learn a new set of libraries. And Jython has solid support behind it from SUN.
If you program in C# or VB, learn Python because you can get that same advantage, leveraging all your existing libraries and classes while reducing the lines of code that you have to write. And IronPython http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython has solid support behind it from Microsoft.
If you need to write code for yourself, from simple scripts up to cross-platform applications, then learn Python and use one of the distros of the standard CPython such as ActiveState or Enthought. Or roll your own by downloading from http://www.python.org/ and adding the libraries that you need. Want to build wxWindows apps crossplatform? wxPython does it. Want GTK apps cross-platform? The pyGTK is the library for you. Need to distribute Windows binaries? Use Py2exe. Or for OS/X use Py2app and on UNIX use freeze.
Python has 10 years of widespread use behind it with people building everything from multi-thousand lines-of-code apps to system admin scripts. If you want to learn how to write threaded apps, Python lets you focus on the essentials. Or if you want to avoid threading and build asynchronous servers or true parallel apps, Python has modules for that as well.
If you are already a master of three or more current programming languages (not COBOL) then maybe you won't gain anything by learning Python, but every other programmer really should make it part of their toolbox. If nothing else, use it to build quick prototypes, then when it's write, redo it in C++ or Java for the final delivery. The boss will not complain if it reduces the turnaround time for your projects. -
Re:FastCGI != Apache Module
PHP used to also ship as an ISAPI module, but it did pretty much the same thing that the CGI did- reload the interpreter for every single request. I'm not sure why they bothered with FastCGI when it would've required about the same amount of effort to write an ISAPI extension. It might have to do with the fact that PHP's source code was more spaghetti-like than any PHP code one could dream up, and not trivial to follow or modify.
It would be interesting to compare the performance to that of Python [insert framework name here] on Windows, both the ISAPI version and the FastCGI version. -
Re:But what is going to be obsolete ?I've seen so many people claiming to know Java, C# and whatnot, just to give me that incredibly blank stare when I ask them for hash tables. Yes, they know every function, every class in Java by heart, but they have no knowledge of what they should actually DO with it.
Now, it might not be a "necessity" tomorrow when there is a function that does it for you. But it is VERY easy to learn about a function (hell, look it up, it ain't like there's no online help file for it) while it is not so trivial to understand what it actually DOES. You mean like a dict? Yeah, I really don't care that it is a hash table. I just care about its properties: unique keys that must be immutable. Values that can be mutable. Methods for testing membership are "d.has_key(x)" or "if x in d" and so on... And I care that it's fast already, so I don't have to reinvent the wheel (hash table), which would almost certainly be slower than the C-coded, optimized built-in.
Why should I care again? It's not going to break on me. It's going to have the same exact properties I already mentioned every time I use it. I guess I could subclass the dict type and write my own (slower) sorting and membership testing functions if I felt like being a masochist one day, but why? -
Re:I don't understand...
For some config files, XML is the easiest way to go. I wrote an app that stores the entire hierarchy of the GUI's frames, panels, and values as nested nodes of XML. The app then looks at those XML nodes and recreates itself accordingly when loading the config. Using python's xml.dom.minidom makes it easier to work with.
I agree that in most cases it is overkill, if you know exactly which values need to go where, python's config parser is much easier and the resulting files are smaller.
Regarding CSV files and the like, again they are sufficient when dealing with 2D data, but once you get into hierarchal structures it becomes much more effort on the part of the program's logic and processing. Also the legibility of the files are better, if indented correctly with something like toprettyxml of course. At that point though it's even easier to go with SQL, unless high portability and/or transfer is required.
As more often than not it's the application that is good or bad, not the tool. XML can be a great tool, if chosen and used correctly. -
Re:I don't understand...
For some config files, XML is the easiest way to go. I wrote an app that stores the entire hierarchy of the GUI's frames, panels, and values as nested nodes of XML. The app then looks at those XML nodes and recreates itself accordingly when loading the config. Using python's xml.dom.minidom makes it easier to work with.
I agree that in most cases it is overkill, if you know exactly which values need to go where, python's config parser is much easier and the resulting files are smaller.
Regarding CSV files and the like, again they are sufficient when dealing with 2D data, but once you get into hierarchal structures it becomes much more effort on the part of the program's logic and processing. Also the legibility of the files are better, if indented correctly with something like toprettyxml of course. At that point though it's even easier to go with SQL, unless high portability and/or transfer is required.
As more often than not it's the application that is good or bad, not the tool. XML can be a great tool, if chosen and used correctly. -
Re:I don't understand...It can't be processed with the likes of awk and sed.
Just because you can't use tools made for processing text in Unix line-based format, doesn't mean there aren't tools for this purpose. You can even find tools inspired on awk for XML processing, like xmlgawk (also here).
However...
I agree with you that XML is not the answer for everything. For instance, I just hate XML configuration files, exactly because you can't reliably grep, sed, awk, ex, them. Editing XML with vi is not the nicest task either. For config files I usually like INI-style files, for which there are modules in Python and Perl, and you can easily get around with simple shell tools when you just need a dirty hack. A config file usually has a simple enough structure to allow you to specify anything you need in the constraints of INI files (if it doesn't, you should probably rethink your config, it's probably bloated!).
For other tasks such as tabular data, CSV or just plain text delimited by tabs or ":" (think
/etc/passwd) are more suited than XML, exactly for the ability to use simple universal tools (grep, sed, awk) on the data. It's even easier to visually inspect a table if it's in CSV or tab-delimited than it is to inspect an XML file and try to see through the tag soup.Your comment about logfiles is right on the spot! Log files are just made to be grepped. Anything that doesn't write all relevant information of an action on one line, at the time the action happened, really defeats the purpose of logging.
-
Re:Damn right
To expand on that:
4. Unicode will become the standard throughout Python. This is probably the biggest change. Whereas before the String datatype was synonymous with a byte array (and used for both), it no longer will be. This entails some additional changes in your code to specify the encoding of a String, which will now be represented as Unicode. A new datatype, called "Bytes" (IIRC) can replace the former byte array use of Strings.
5. Many modules in the Standard Library which have been marked deprecated for several versions now (and raised a DeprecationWarning exception) will now actually be removed. Several others with old naming conventions, ambiguous names, or dual Python/C implementations will be renamed, with an appropriate backward-compatible stub that issues the same DeprecationWarning exception, but still works with the old name. A running tally of modules to be removed/renamed is in PEP 3108.
The bottom line is that they are not just making backward-incompatible changes for the sake of changing things. They are specifically trying to avoid "becoming the next Perl 6" to paraphrase Guido from one of his Google Tech Talks. They are just taking this one chance to remove longstanding "warts" from the language in one fell swoop.
Almost everything will be covered by the 2to3 converter. Where required changes are ambiguous, 2to3 will issue a warning and request you fix it manually. I'd rather they fix the problems with the language now before they get any more entrenched. But then, I'm not a maintainer of "legacy" Python code. I am looking forward to the Generic Functions and Adaptation features (among other things) that are being discussed for Python 3000 though. -
Re:Python to not be backwards compatible
The Python 2 to Python 3 transition is not the same as Perl 5 to Perl 6. Perl 6 is a major rethinking of Perl, with a lot of changes. Python 3 is still very similar to Python 2 with very few syntactical changes - the primary motivation for Python 3 to break backwards compatability was to be able to purge implementation cruft from the language that was mostly derived from early design mistakes.
It's true that you'll need to do work to port/test code from Python 2 to Python 3, but learning the syntactical differences can be done in an afternoon, as there aren't that many:
http://docs.python.org/dev/3.0/whatsnew/3.0.html -
Re:print as function vs. keyword
You are correct, but the common case of printing one value is identical. Read PEP 3105 for the details.