Posts about python (old posts, page 13)

2007-09-05 09:46


Well, it seems I am in trouble for PyWeek.

Why? Because it's wednesday and I have done nothing. Nothing! It's because I have been working a lot, really, and I have a 4 month baby, too.

So, I am upping the ante.

I will do a PyDay.

I am taking tomorrow off (yeah, right!) and I'm doing the game in one day. Maybe I will scrounge a few hours on sunday, too.

It will probably not be fit for the contest because:

  • I will use PyQt
  • I won't test it in any platform other than my Linux box

But here's the game concept (BTW: Twisted sucks as a theme. It sucks really, really, really hard!):

According to the dictionary, Twisted also means perverted. So, this game, Twisted Little Boy is about a bad boy. A really bad boy. But a clever one. He creates machines using random equipment he finds to do evil, really mean things.

I will probably do a live-blog thing like those tutorials I wrote years ago about PyQt.

There's a Google code project (obviously empty):

See you all tomorrow.

2007-08-13 17:59

Django, the view from a parachute

In the last few days I have been learning Django in perhaps the hardest way possible: by being hired to work on a site someone else wrote.

I already had the view from 10000 feet. And since I had to get to this thing rather quickly, I jumped on my parachute from those 10000 feet, and learned it on the way down.

Here's what I knew:

  • Python Web framework
  • Regexp-based URL dispatching
  • Its own template language
  • Its own ORM and form stuff

I have hacked stuff based on TurboGears, Colubrid, pure CherryPy, Mako/Kid/Cheetah/CherryTemplate templates, Routes, Paste and about half a dozen other frameworks or pieces that are used for frameworks, so how new could it be? Well, not very new. I am starting to notice a sort of sameness in these things. They are all alike.

First, the conclusion: I liked it, I could work with it.

Now for some little detail:

  • The URL dispatching is nice ,if not really interesting. there seem to be two ways to do this, all frameworks use one or the other, and almost everyone likes regexps better.
  • The ORM+newforms is quite nice! Of course everything was done with oldforms, which is... not quite so nice. But you can switch pieces as you go, and the code actually simplifies as you hack, so it's good.
  • The template language I could live without. It doesn't seem to be specially featureful, and it didn't seem as expressive to me as my current favourite, Mako. Luckily you can replace it easily. It's not that it's bad, it's just average.

So, I see no reason to learn it instead of Turbogears, or viceversa. On the other hand, if you know one, you can learn the other in perhaps a weekend, so there's no point on not having at least a basic knowledge of both.

2007-08-08 10:59

Be afraid, young pumpkins!

Allow me to enter trash-talking mode...

Be very afraid because this year, my mighty skills are entering PyWeek for the first time.

Just to make it interesting and somewhat challenging:

  • I will be entering as an individual, not in a team.
  • I have not written a line of PyGame code in my life.
  • I have written barely any game code at all.
  • I will submit my final code one day earlier, just because I can.

Nonetheless, I intend to kick asses and ask no questions. I intend to overwhelm you all with a game of such awesomeness you will all whither like lettuce in Lapland. I will write code of such ingenuity you will try to steal it and fail.

...exiting mode.

Should be fun and my entry will probably suck. But we'll see...

2007-08-08 09:05

Me and FLOSS in the late '90s

I have no idea how, but I ran into this in Linuxtoday:

KDE Programming Tutorial 0.2 (Dec 22nd 1998, 00:09:36 )
Roberto Alsina announced that he uploaded to the version 0.2 of his excellent programming tutorial. It is also available here. Hopefully, this must-have material will be soon included in the kdesdk package and in CVS.

Now, this was pretty shocking because I don't remember writing it (anyone knows where a copy may be?). I have no idea what was in it, and in fact, the idea of people learning C++ from me in 1998 is so stupid it's shocking, since I knew very little.

Then it hit me, the URL! Ultra7? That was my 486 at college [1].

It had a webserver? What on earth had I been drinking back then? Why can't I remember this???

Wayback machine, come here! Fetch!

Here's my first home page. I must say it's pretty good. It's not garish. Very Web2.0 in the abundant white space.

First interesting thing: there is at least one extant copy of PyXForms, my first free software project, used by absolutely noone.

And there are even two cool screenshot of a functional program noone ever used [2]:


In fact, I have no idea how I did that highlighted message display.

Then all that proto-good taste goes away when you reach the page for my most "popular" project ever... Krn in my 1999 home page [4]. It' so 1999 free software style. All that's missing is an electric blue background.

It seems I had discovered The Gimp and it's banner scripts!

BTW: I wonder what's Magnus Reftel doing nowadays? We used to exchange dozens of mails a day and for some reason we lost contact.

There was also a mailing list archive for the very very very first posts of our proto LUG (which would later become LUGLI)

And here's the best part, and the one that makes me kinda sad... Themes for Qt1.

You can read a little about them in this thread.

I have written about them once or twice before but here's the short version:

Rasterman was starting to hack themes for Gtk. I decided they couldn't be the only ones with this cool new technology but I had the big disadvantage of not being able to touch Qt's code because of licensing issues. So I intercepted the drawing events using a LD_PRELOAD hack and implemented a theme full of gradients without modifying or recompiling Qt or KDE.

Now that's one of the most impressive hacks I have ever performed, even if it was a hack done with the most evil code ever, and... there seems to be no extant copy of the code or the screenshots.

Which is kinda sad, indeed.

[1] UNL, where every computer had a public IP address!
[2] The idea was a sort of GUI Pine, all handled with single key strokes. I still pine for that program! [3]
[3] And for the fjords.
[4] AKA the buggiest program ever to be part of KDE proper.

2007-08-07 08:21

Fixing old tutorials

I got a mail from a reader telling me that he couldn't download the sources for Notty, the toy app I developed in my Rapid Application development using PyQt and Eric3 ... in realtime! tutorial.

So, I checked and was shocked at just how much the server moves had wrecked that article, which is one of my favourites!

No images, broken link to the sources, no syntax highlights!

So, I rejiggered the thing quickly with some search and replace (thanks restructured text!) and now it should be up to standards, except that... it's still about Qt3 and I am not even sure it works nowadays.

Normally that would be simple to fix: change the code as needed, make it work, and be happy.

But the fun thing about that article was that it was written in 3 hours, and it talks about how it was written in 3 hours. So, I think I may have to do keep that and add a note with a link to a corrected/updated one, someday.

2007-08-04 14:49

Coming ideas

Nowadays, the very little time I have for personal projects is spent doing things like fixing little things and adding little features to BartleBlog [1] and thinking how I could use GLE and mako templates to create a cool nerdy tool to create charts.

However, I will be having a little time for personal projects in a couple of weeks, and having stumbled onto chipmunk today really got me thinking.

It's a seriously nifty 2D physics library. Consider this demo video:

Now, what could possibly be done with it... I need to really think.

[1] What I use to post this.

2007-07-05 11:07

Quote of the day (ok, of May 21st, 2007, but I only saw it today)

Said Giles Bowkett

The Perl community's starting to look more and more like the Lisp community every day. The combination of incredible power, reclusive wizards, and antisocial Slashdotters gives it the vibe of a lava-filled wasteland dotted with towers where strange men with white beards obsess over unspeakable knowledge. I spoke to someone once who compared programming in Lisp to studying Kabbalah, in that it does strange things to your head. Parts of Perl are like that. Still, source filtering's kind of cool. Unnecessary, but cool.

So, now we know. Saruman used too much Perl.

2007-06-04 13:42

Sometimes, you need to do it the hard way.

You may have noticed no posts about StupidSheet for about a week.

Well, I ran into the limitations of the formula parser I was doing using Aperiot. I just couldn't make it parse this:


So, I spent the next week trying one parsing package for Python a day until I could find one I understood and could make it parse that example.

I must say it was educational.

So, now the parser is based on PLY which is pretty much Lex+YACC with a (slightly more) pythonic syntax, and it works.

Yes, it's a bit harder, but by trying to do things simply I was limiting myself too much, and, perhaps underestimating myself.

I am a pretty smart guy, there is no reason I can't understand these things.

2007-05-30 14:05

Almost a real spreadsheet! (with video)

I was able to hack a bit at StupidSheet this morning, and there are some real advances.

In fact, it's a barely functional spreadsheet already! Hell, it has at least one feature OOcalc lacks, and one both OOcalc and KSpread missed.

Check it out in this video (9.5MB):

Sorry, dead file

Sorry if the audio is out of sync and/or too low. And you probably can't stream it, you need to download it first. And maybe it will 404 on you. If that's the case, wait a few minutes and insist.

2007-05-29 09:19

Stupid Sheet: Redoing cell displacements

For my spreadsheet project, I had to redo something I had forgotten about: cell displacement. I did that once when the formula language was python.

At the time, I parsed the python using the tokenize module and Ka-Ping Yee's regurgitate.

Python->Tokens->Displace cells->regurgitate->Python

Since I have lots of other things to do, I decided to do it the same way, and wrote the equivalent of regurgitate for Traxter, my formula language.

It turns out it was not really hard, but I had to redo parts of the parser so it kept more information about the source.

After that it was simple, you see, Traxter compiles to Python. That means all I had to do was another (very similar) backend, and there it is, a Traxter-to-Traxter compiler. Or decompiler. Or something. And relative cell references are working again (and now with the right syntax).

Contents © 2000-2019 Roberto Alsina