Developer

To Python or not to Python

Python has gained popularity because it's an open source programming language that's easy to learn and accessible to a number of different operating systems. Jacob Wilkins discusses why programmers are choosing Python.


TechProGuild held an online chat on September 14, 2000, in which Jacob Wilkins discussed why programmers are choosing Python. Here's the transcript from that chat.

Note: TechProGuild edits Guild Meeting transcripts for clarity.

Welcome to tonight’s discussion on Python
MODERATOR: Tonight we are very glad to have Jacob Robert Wilkins here to discuss Python! And I don't want you to forget that we are giving away a motherboard, processor, and fan from PogoLinux as this month’s prize!

PERL versus Python
JACOB ROBERT WILKINS: Who here has used Python?

ANDY_DAVIS: Not yet.

T_LINDSEY: Nope.

MODERATOR: I've only dabbled in it, but I was impressed.

KEVINOSAR: Not yet here also.

JACOB ROBERT WILKINS: OK, who has used PERL?

ANDY_DAVIS: I haven’t used PERL; I’m looking at PHP now.

T_LINDSEY: I haven’t used PERL either.

TLSNC: Not me either.

JACOB ROBERT WILKINS: Well, the reason I ask is that most tasks that can easily be done in PERL can also be done in Python. Python just has a much cleaner syntax. The rumors are true: Python does use white space for syntax. But it flows very well. The official Web site, www.python.org, has a good tutorial.

MODERATOR: I bought the O'Reilly book and found it to be pretty amazing. I had a Windows application going with four lines of code! Of course I couldn't figure out how to make it do anything, but that was only for lack of trying.

KEVINOSAR: What are the advantages/disadvantages of Python over PERL?

T_LINDSEY: Good question, Kevin. With PERL being used so much in CGI, why should I look at PERL?

JACOB ROBERT WILKINS: The biggest advantage Python has over PERL is usability. Python code is easy to read and easy to write, and also, Python supports object-oriented programming constructs much better than PERL. PERL's object-oriented programming is very much "welded on," while Python's is "built in." There is a PERL module for everything from handling CGI information to making coffee. The disadvantage of Python right now is no CPAN.

T_LINDSEY: What is CPAN?

ANDY_DAVIS: CPAN stands for Comprehensive PERL Archive Network.

KEVINOSAR: Python can be used for handling CGI information also, can't it?

JACOB ROBERT WILKINS: Yes, there is a CGI module for Python. It makes it very easy to do simple form handling. There is also an application server called Zope, at www.zope.org, written in Python.

Easy to Learn
T_LINDSEY: Compare Python versus PERL for learnability.

JACOB ROBERT WILKINS: Python is infinitely more learnable than PERL. Python is probably the best language for new programmers to start with. You can start writing powerful code quickly. I use it all the time. The number one task I use it for is unmangling data in text files and sticking it in databases. There’s no telling what format they are going to send you data.

ANDY_DAVIS: You can use it with databases?

JACOB ROBERT WILKINS: Yeah, there are modules that let you make connections to just about any type of RDBMS.

T_LINDSEY: How long have you been coding in it?

JACOB ROBERT WILKINS: About 1.5 years now. I do a lot of Web consulting and data driving Web sites.

KEVINOSAR: Is there any reason why Python hasn't caught on to a bigger audience than what it already has?

JACOB ROBERT WILKINS: It’s much newer than PERL.

WELL: Is Python easy to learn?

T_LINDSEY: Jacob Robert Wilkins seems to think so. So did Jack Wallen.

WELL: As we know, programming is not easy to learn.

JACOB ROBERT WILKINS: Python is.

WELL: I don’t know anything about programming. Any suggestions?

T_LINDSEY: The tutorial at honors.montana.edu is written for nonprogrammers.

WELL: You have to learn the basics before you can learn any programming.

T_LINDSEY: Does it provide random natalie portman posts too?

JACOB ROBERT WILKINS: No, you have to install the HotGrits package to get those.

WELL: Maybe you can suggest a Web site that provides info about programming?

JACOB ROBERT WILKINS: Start with the tutorial at http://www.python.org/doc/current/tut/tut.html. Http://www.pythonlabs.com is another good place to start.

T_LINDSEY: http://www.honors.montana.edu/~jjc/easytut/easytut/ is another site for a tutorial on Python.

JACOB ROBERT WILKINS: Version 2.0 is out in beta. It provides some nice little updates to the syntax. It adds the += operator, so you can do x+=1 rather than x=x+1

WELL: I’d better learn Java.

JACOB ROBERT WILKINS: Python is better than Java for a number of tasks. Java's footprint is huge!

T_LINDSEY: Really huge.

JACOB ROBERT WILKINS: Python is fairly small and fast.

AWK and SED
T_LINDSEY: So you can use it like awk and sed too?

JACOB ROBERT WILKINS: You would use Python instead of sed and awk.

T_LINDSEY: I like the sound of that. I’m just now learning awk and sed.

JACOB ROBERT WILKINS: PERL is just a glorified replacement for sed, awk, sort, cut, tr, and numerous other shell scripting tools, such as MySQL, Postgres, Sybase, Oracle, and many, many more. Sed and awk are really "old school"; PERL or Python is the modern answer.

T_LINDSEY: But awk and sed are on the LPI level one test.

So, say a customer is using Oracle. You could write a Python CGI app for the Web site to input data into it?

JACOB ROBERT WILKINS: Yeah, you could. But doing anything important in CGI isn't a good idea. At that point, you probably use Zope. Or limit the Python to back-end maintenance scripts, like batch imports. You can even do GUI in Python. I haven't messed much with that, but you can write full-scale Gnome applications in Python.

Moving Data between Systems
KEVINOSAR: Python is also good at binding applications together, isn't it?

JACOB ROBERT WILKINS: Kevinosar, I'm not sure what you mean by that.

KEVINOSAR: I mean that you could take proprietary applications and use Python to move data between systems.

JACOB ROBERT WILKINS: Exactly, that’s the number one thing I use it for. For example, suppose a client gives you an ugly piece of non-relation, fixed-width field data and wants it somehow on the Web. You can use Python to stick it into a MySQL database, with a PHP or JSP front end.

T_LINDSEY: Hey! Clients wouldn't do that. Clients always have a clear vision of their Web site.

ANDY_DAVIS: What about using an Excel spreadsheet?

JACOB ROBERT WILKINS: On Windows, there are COM interfaces for Python, so yes, you can open Excel spreadsheets and Access databases. I've not used Python much on Windows, but I know it works very well.

Interpreted Language
T_LINDSEY: Is Python an interpreted language like PERL?

JACOB ROBERT WILKINS: Python is interpreted but also byte compiled like Java.

Python Web site
KEVINOSAR: Are there any other Web sites other than the two you listed where one can learn more about Python?

JACOB ROBERT WILKINS: You should go to the Python Web site, www.python.org, and check out the tutorial.

Python codes
T_LINDSEY: I've heard of PERL "one liners," a PERL script written out on one CL. Can Python do this too?

JACOB ROBERT WILKINS: Well, you can write pretty compact code in Python, but no, not really. But that’s not really a bad thing. The problem with lots of PERL code is that it looks like line noise.

KEVINOSAR: What are some of the disadvantages that Python has in relation to PERL?

JACOB ROBERT WILKINS: Some people can't get over the fact that Python is white space sensitive. There are a few PERL tricks like editing files in place on the file system that Python can't do. But for everyday use, I'd say it’s better than PERL.

T_LINDSEY: Can you explain what you mean by "editing files in place"?

JACOB ROBERT WILKINS: It’s pretty much what it says: It doesn’t read the file into memory before operating. It’s a funky PERLism with which I am not largely familiar, after all, I'm a Python programmer.

T_LINDSEY: Ah, that's what I thought you meant. Thanks.

JACOB ROBERT WILKINS: Eric Raymond (hero to the Open Source movement) says that while PERL has a bigger user base, Python's users tend to have a higher degree of skill. It’s just a more elegant language.

ZOPE
KEVINOSAR: Can you tell us more about the ZOPE application?

JACOB ROBERT WILKINS: Zope is a full-blown application server/content management system written in Python and extendable via Python. It’s completely free.

KEVINOSAR: Free is nice.

JACOB ROBERT WILKINS: It started as a commercial package from Digital Creations, but their sales weren't good, so they open sourced it, and sell consulting around it. (Check out www.zope.org.) It’s at the same level of quality as Netscape Application Server and BEA Weblogic. Zope has some neat prewritten packages, like the SquishDot package. It lets you drop a slashdot.org type interface into your Web site. Www.technocrat.net uses Zope.

Python’s future
KEVINOSAR: Where do you see Python being used in the future? Are there any new developments?

JACOB ROBERT WILKINS: Well, Zope is gaining momentum. There are a number of Open Source projects that are written in Python already. And Python is quickly becoming the "PERL" of the OO programming crowd. That’s just a case of using the right tool for the right job.

WELL: Is Python gaining more popularity than Java? It's quite new to me, as Java can be heard anywhere to create a homepage.

JACOB ROBERT WILKINS: You can write and run a small Python program to mangle some data much faster than in Java.

JACOB ROBERT WILKINS: Python has regex capability built in. Python has much lighter array and list manipulation.

WELL: Can we simply use Python to create homepage?

JACOB ROBERT WILKINS: It’s easy to do simple form handling in Python, if that’s what you mean.

T_LINDSEY: I think he means to do the whole HTML

JACOB ROBERT WILKINS: Python is not a "Web-centric" language.

T_LINDSEY: I thought you said it could do CGI apps?

JACOB ROBERT WILKINS: Most all of the tasks you do in Python, you could do in Java, but it would take more code to do the same amount of work.

KEVINOSAR: Sounds like it’s time to go through those Web sites to learn more about Python.

JACOB ROBERT WILKINS: Yeah, hit the tutorial.

T_LINDSEY: Agreed; I will probably run though the tutorial at least.

JACOB ROBERT WILKINS: You'll be surprised at how simple Python really is.

T_LINDSEY: Sounds like a good language to start with Is Python to PERL as Java is to C?

JACOB ROBERT WILKINS: T_LINDSEY: Not quite, Python and PERL run at about the same speed. Java is slower, and C is faster.

T_LINDSEY: Gotcha.

Closing Time
MODERATOR: I'd like to thank our speaker tonight—the ever gracious and interesting Jacob Wilkins! I hope Jacob would be willing to come back after we've all had some time to try out Python

JACOB ROBERT WILKINS: Most definitely. These things are fun; I hope to come back and speak again.

MODERATOR: Meanwhile, tonight's winner is t_lindsey! T_lindsey send your real name and contact info to tpgedit@techrepublic.com. That means you're now in the running for that motherboard and CPU. If you win the most meetings this month, you'll take those hardware items home! Everyone, thanks for such a good turn out!

Editor's Picks