Archive for the 'Python' Category

Brain candy

Wednesday, March 15th, 2006

Last night I stayed up late reading Learning Python. Most of it was ordinary programming stuff — “This is a function” — but here are the three things that got me excited and almost gave me goosebumps. First, being able to return tuples from a function (so you can return multiple values from a single function). Wow. Second, map(), which lets you run a specified function on a list. (It’s equivalent to iterating through the list and calling the function manually, but much cooler.) Third, lambdas. Hmm, how can I describe lambdas? In-line functions? That’s not a very useful description per se, but oh well. :) Apparently lambdas are one of the things that make Lisp so cool, and I can see why. I’ve been reading about metaprogramming and it looks quite interesting (and ESR mentions it in his article, linked to in my last post). Yum. :)

I doubt I’ll ever go back to C now. :)

Technorati Tags: ,

Python goodness

Tuesday, March 14th, 2006

The more I read about Python, the more I’m liking it. (See Eric S. Raymond’s Why Python?, for example.) I suppose that if I upgraded to Tiger, the binding problem I had would go away. So, if that does indeed happen, I suspect I’ll be doing most of my Mac development in Python rather than Objective-C. :)

Technorati Tags: , ,

Python around my neck

Saturday, March 11th, 2006

I’m supposed to be in bed (early meeting tomorrow morning) but I figured I’d quickly mention this. I downloaded and installed PyObjC today and tried to get the sample program (from Apple’s website) working, and I was so close, but for some reason my Xcode (1.5, on OS X 10.3.9) wouldn’t show the Averager in the binding tab of the info dialog. I’m pretty sure I followed the instructions correctly, and I even watched the Quicktime movie to double-check that I was doing it right, but with no luck. Oh, and I downloaded the project from their site and opened it and the info dialog said it was hooked to Averager (for “value”) but when I expanded the value thingie, it went away and I was left with just “System Defaults” and the other one, which I can’t remember at the moment. Anyway, I’m not sure what the source of the problem is here, but I may just go back to Objective-C for now…

Technorati Tags: , , , ,

Wordsmith

Friday, March 10th, 2006

In my linguistics classes, we’re doing stuff with text processing/analysis software (like WordCruncher) that’s Windows-only, and it’s a shame. How hard would it be to write a text analysis engine in Perl or Python and a frontend in PyObjC? It can’t be that hard… Perhaps I’ll use that as my learning program for Python — start small and build up. So, the next question then is what text analysis software ought to do. There’s got to be a ton of different ways to look at a text computationally — wordprint analyses, statistics of various types, etc. The engine would also have to support tagging the text, so you could say “This word is a verb, 3rd person singular present active indicative” or “This is a conjunction” or whatever. I really only have experience with WordCruncher, but in my research class we looked at some Oxford tools a month or two ago which seemed to be the same sort of thing.

But in all reality, to make this project worth my time (and to keep my interest), it has to be something I care about. Adding statistics on end won’t cut it. So, what does it need to do to be useful? For me, it’d be nice to make a list of the top x (50 or 100 or 1000 or whatnot) words in a text. Foreign language texts are important to me as well, and I can see this tool (let’s call it Wordsmith for now) being of some use in preparing texts for Riverglen Press “publication.” In fact, that’s a good way to ensure that it will be useful, to me at least — focus it on helping with production for Riverglen Press. Excellent…

Technorati Tags: , , , , ,

Help! Help! I’m being oppressed!

Thursday, March 9th, 2006

At the library today I browsed through the Python section (QA 76.73 .P98 or so, if you care to know :) ) and picked up O’Reilly’s Learning Python. Spent the last hour going through the first chapter and a half. Good stuff. It’s surprisingly easy to learn, and gosh it’s fun! (I think my delight stems from 1) the fact that I haven’t really learned any substantially new languages in a while and 2) it’s interpreted, so results come immediately, and 3) it’s a cool language.) This language-learning thing is addicting. I can’t wait to learn Ruby and Lisp/Scheme and more Perl… Anyway, the main thing is to start coding real things in it, so I’ll have to come up with some small mini-programs that’ll help me get my bearings. And then it’ll be time to learn PyObjC and see if it’s feasible for writing Beyond. I think it is — Apple’s website seems to indicate that you can do anything you need to with it — and it’ll be soooooo nice not to have to take care of memory management. :)

And yes, TextMate is still slow. Backspacing, especially. Hmm. If I can’t figure out a way to fix it, it’ll be bye-bye TextMate and hello again to vim. (TextWrangler is okay but the interface is kind of clunky.)

Technorati Tags: , , , , , , ,