Skip to main content

Ralsina.Me — Roberto Alsina's website

Posts about python (old posts, page 25)

Coming ideas

Nowa­days, the very lit­tle time I have for per­son­al projects is spent do­ing things like fix­ing lit­tle things and adding lit­tle fea­tures to Bartle­Blog [1] and think­ing how I could use GLE and mako tem­plates to cre­ate a cool nerdy tool to cre­ate chart­s.

How­ev­er, I will be hav­ing a lit­tle time for per­son­al projects in a cou­ple of week­s, and hav­ing stum­bled on­to chip­munk to­day re­al­ly got me think­ing.

It's a se­ri­ous­ly nifty 2D physics li­brary. Con­sid­er this de­mo video:

Now, what could pos­si­bly be done with it... I need to re­al­ly think.

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

Said Giles Bowkett

The Perl com­mu­ni­ty's start­ing to look more and more like the Lisp com­mu­ni­ty ev­ery day. The com­bi­na­tion of in­cred­i­ble pow­er, reclu­sive wiz­ard­s, and an­ti­so­cial Slash­dot­ters gives it the vibe of a lava-­filled waste­land dot­ted with tow­ers where strange men with white beards ob­sess over un­speak­able knowl­edge. I spoke to some­one once who com­pared pro­gram­ming in Lisp to study­ing Kab­bal­ah, in that it does strange things to your head. Parts of Perl are like that. Stil­l, source fil­ter­ing's kind of cool. Un­nec­es­sary, but cool.

So, now we know. Saru­man used too much Per­l.

Sometimes, you need to do it the hard way.

You may have no­ticed no posts about Stupid­Sheet for about a week.

Well, I ran in­to the lim­i­ta­tions of the for­mu­la pars­er I was do­ing us­ing Ape­ri­ot. I just could­n't make it parse this:

A1=IF(A2=B2,1,0)

So, I spent the next week try­ing one pars­ing pack­age for Python a day un­til I could find one I un­der­stood and could make it parse that ex­am­ple.

I must say it was ed­u­ca­tion­al.

So, now the pars­er is based on PLY which is pret­ty much Lex+Y­ACC with a (s­light­ly more) python­ic syn­tax, and it work­s.

Yes, it's a bit hard­er, but by try­ing to do things sim­ply I was lim­it­ing my­self too much, and, per­haps un­der­es­ti­mat­ing my­self.

I am a pret­ty smart guy, there is no rea­son I can't un­der­stand these things.

Almost a real spreadsheet! (with video)

I was able to hack a bit at Stupid­Sheet this morn­ing, and there are some re­al ad­vances.

In fac­t, it's a bare­ly func­tion­al spread­sheet al­ready! Hel­l, it has at least one fea­ture OOcalc lack­s, and one both OOcalc and KSpread missed.

Check it out in this video (9.5M­B):

Sor­ry, dead file

Sor­ry if the au­dio is out of sync and/or too low. And you prob­a­bly can't stream it, you need to down­load it first. And maybe it will 404 on you. If that's the case, wait a few min­utes and in­sist.

Stupid Sheet: Redoing cell displacements

For my spread­sheet pro­jec­t, I had to re­do some­thing I had for­got­ten about: cell dis­place­men­t. I did that once when the for­mu­la lan­guage was python.

At the time, I parsed the python us­ing the to­k­enize mod­ule and Ka-Ping Yee's re­gur­gi­tate.

Python->­To­ken­s->Dis­place cell­s->re­gur­gi­tate->Python

Since I have lots of oth­er things to do, I de­cid­ed to do it the same way, and wrote the equiv­a­lent of re­gur­gi­tate for Trax­ter, my for­mu­la lan­guage.

It turns out it was not re­al­ly hard, but I had to re­do parts of the pars­er so it kept more in­for­ma­tion about the source.

Af­ter that it was sim­ple, you see, Trax­ter com­piles to Python. That means all I had to do was an­oth­er (very sim­i­lar) back­end, and there it is, a Trax­ter-­to-­Trax­ter com­pil­er. Or de­com­pil­er. Or some­thing. And rel­a­tive cell ref­er­ences are work­ing again (and now with the right syn­tax).


Contents © 2000-2023 Roberto Alsina