Skip to main content

Ralsina.Me — Roberto Alsina's website

Extreme code reuse

I am, as al­ways, play­ing with stuff. And I was faced with a prob­lem I must have solved a dozen times be­fore:

Giv­en a list of items with ob­vi­ous hi­er­ar­chi­cal names (say, a list of fold­er­s), turn it in­to a rea­son­able da­ta struc­ture.

Since there are not all that many names, there is no need to do it on-de­mand, or any­thing like that.

I must con­fess I suck at this kind of things be­cause I hve to ac­tu­al­ly think them through. I don't know how to do this kind of things.

Mind you, I have done it be­fore, but I said, hey, maybe google can help me...

And yeah! Python code from 1994 that does ex­act­ly what I need­ed. I had to touch a sin­gle line ( string.s­plit­field­s(a,'.') to a.s­plit('/') ) and it worked.

The In­ter­net nev­er for­get­s!


Contents © 2000-2023 Roberto Alsina