Python


#1

So is there any reason not to consider Python the perfect scripting language? I’ve been trying to get into it and I think I finally have a project that will keep my attention longer than “Hellow World” and porting my PHP apps as an exercise.

Book recommendations would be great also. I know what there is online, but I like reading stuff while on the crapper, the bus, between drive bys, etc.


#2

Whitespace sensitivity. :P But aside from that, it’s pretty nifty, and I’ve used it for a few small scripts that would have been a lot more painful in Perl or bash. I’ve just been using O’Reilly’s “Learning Python” for a print tutorial and reference.

I’m not a web developer though, and a friend of mine who is used to like Python but now swears by Ruby On Rails, though I couldn’t tell you anything about it myself.


#3

Python rocks. For books, I recommend “The Python Cookbook, 2e” to get an idea of what the language can do. I actually found “Learning Python” to be abysmal and much prefer “Python in a Nutshell”.

For Web stuff look at Django and TurboGears. I love the latter.


#4

I use Python extensively in AI, natural language processing and web applications. Like Bacon I’m a big TurboGears fan (but I wish they would fix the logging configuration issues). 1.01beta just came out.

You can’t beat string processing in Python except with something like Perl or Lisp. Both of those languages have other severe drawbacks which usually keep them out of the picture.

As for books, there isn’t one that I keep coming back to regularly, so I don’t have a good recommendation there. I do recommend going to the Cheeseshop and just taking a look at what other people have done.


#5

Print out the Library Reference and keep it under your pillow.


#6

Yeah, it has problems. http://www.amk.ca/python/writing/warts.html

The scoping rules are described on that list as fixed, but the new rules still have some surprising side-effects when combined with the lack of variable declarations. As I found out in a recent thread.

The type/class dichotomy isn’t “fixed” either, just somewhat mitigated, because Guido wasn’t willing to screw backwards compatibility for it.

Still my current favorite language, though.


#7

I’ve played around with Ruby some. The concept of an OO scripting language without any of that whitespace significance appeals to me. I wish I got more chance to write in it though, every time i write a script its like starting at square 1.


#8

Python beats out any other scripting language I’ve tried, at least for me. Library support is at times a bit thin, but this isn’t really a problem for scripts.

By far the most useful Python book for people who already know how to program I’ve found is Python Essential Reference (although I only have the 2nd edition). Python in a Nutshell, the O’reily Python Book, and the Python Cookbook simply aren’t as good, IMHO.


#9

The most obvious problem with Python is that it has a pretty crap scoping implementation, which can be overcome, but it makes you have to put in unnecessary code to cover it’s faults.
OTOH it has very comprehensive library, and a large support base.


#10

Eh. Python’s scoping can be a pain in the ass on occasion, but frankly it rarely comes up.


#11

Yeah, I was going to say the same thing, assuming we’re talking about the globals thing.


#12

I’d take a hard look at Ruby before selecting Python, especially if you don’t currently have an investment in either.


#13

I’d take a hard look at Ruby before selecting Python, especially if you don’t currently have an investment in either.

I’ve never seen any real compelling reasons to move to Ruby. The argument is “it’s cleaner”, which generally translates to “it’s newer and thus doesn’t have legacy crap”. Oh, and it’s “more OOP”, which doesn’t buy points with me at all. I happen to like Python’s arbitrary mix of imperative, functional, and OOP features.


#14

I’ve taken hard looks at pretty much all of them, and it really came down to Ruby or Python. I’ve been using PHP for about 7 years now and have a couple experience levels in Java and C/C++. One big thing I want to do is de-couple myself from “web programming”. While PHP can be run from the command line or in a stand alone environment, this is really little more than a novelty. Everyone knows that PHP apps are web apps.

There are actually a ton of resources online comparing Python and Ruby. One example Google link: here

I’m extremely fastidious and a total type-A, so thinking about things like forcing developers to use specific whitespace conventions and explicitly mentioning self inside classes and such actually pushes extra blood into my corpus cavernosum. Also, there just seems to be less out there about Ruby. Less packages, less job opportunities on the side, etc.

I also couldn’t quickly find anything that would compile Ruby code into a standalone .exe, but I’m sure there’s something out there. I already know there is for Python, which is kind of what started this whole thing.

The nice thing is that I’m not coming from an older Python background, so I don’t have to unlearn old ways of doing things. I’m starting with Python 2.0 and so deprecated orpreviously-broke-but-now-fixed stuff isn’t going to be a factor for me, for instance many of the warts mentioned in the link jim crawford provided (which was a good link, BTW, and I appreciate it).

Thanks for the replies and book recommendations, all. Keep 'em coming if there are more. I can think of a few people who haven’t posted yet who are Python fans.


#15

Python Cookbook is handy, yep. Seconded.


#16

Web programming? Go no further, use Ruby on Rails. If it’s the one thing python is missing is a solid framework like RoR (and yes, I know all about turbogears, django, subway, whatever) – once you get used to the conventions, it becomes a breeze to get something quick together. Or maybe you just want to do non-web scripting?

Here’s a Ruby exe compiler, http://www.erikveen.dds.nl/rubyscript2exe/index.html


#17

If it’s the one thing python is missing is a solid framework like RoR (and yes, I know all about turbogears, django, subway, whatever)

TG and Django both work phenomenally well, I’m not sure what is so compelling about RoR other than it was the first Web stack to really gain popularity.


#18

In the 3 years or so that I’ve been using Python full time, it has never come up.

Python has the smallest set of warts of any language I’ve seen, with those in the list above being all minor and/or already fixed. The most annoying wart I’ve run into is that you can’t do circular imports at the module level, and the biggest problems I’ve run into have all been the dearth of libraries of the sort I need to make games (namely having to maintain my own GUI toolkit because the ones available don’t do what I need).


#19

This bit always amuses me, as the “forced whitespace conventions” are one of the primary complaints I’ve heard about Python, yet the only thing it forces you to do is indent blocks of code, which everyone does anyway. In many languages there’d be grounds for some hot style debate over where to put paranthesis, but in Python that’s moot.

Besides indenting isn’t truly required anyway, since you can still inline things, or split them up arbitrarily over several lines with a backslash, if you find this improves readability. I find python’s whitespace flexibility is no less than the classic C-style, yet the results are less cluttered, and less error prone. I’ve never had a “whitespace error” in Python, but I have had easy to look over parenthesis errors a couple of times in languages with C descendant syntax.


#20

I’ve taken hard looks at pretty much all of them, and it really came down to Ruby or Python. I’ve been using PHP for about 7 years now and have a couple experience levels in Java and C/C++. One big thing I want to do is de-couple myself from “web programming”. While PHP can be run from the command line or in a stand alone environment, this is really little more than a novelty. Everyone knows that PHP apps are web apps.

Speaking as someone who has far too many levels in PHP, I agree with you there. The problem with being a “LAMP” guy (what I’ve done the last few years in my own business) is that LAMP guys don’t make shit for money. It’s embarassing.

If you’re looking for a career upgrade, go for C#/.Net or Java. I’d say C++, but jobs there are getting fewer and farther between. I just picked up Java in the last couple days - for a C++ guy it was surprisingly easy.