How the fuck is trim in Python?

HTFITIP is a website where you can see what a function from one language is called in another (or an implementation).

The idea came to me after the eleventh time I asked myself, how the fuck is trim in Python? It’s called strip by the way.

The website is very simple. On the front page, there’s this form:

How the fuck is _____’s _____ in _____?

The first space is the “source” programming language name, the second one we’ll put the function/method name, and the third one, the “target” programming language. The source language is optional.

A good source for the… source programming language is PHP’s (massive) functions list. First of all, PHP’s seems to have a function for everything, and there’s no namespace so it’s easier for us to build an index of it. Secondly, it’s a widely known language. Thirdly, it’s the first language of a lot of people, so it’s quite possible that a lot of people will want to know what’s the equivalent for PHP’s function X in a new language they’re learning, so if we have to start somewhere might as well be this way.

When the user selects the programming language from the source dropdown, an Ajax call automatically gets all the function names so when the user types a name on the second field, it auto-completes. Then, he selects the “target” language on the third field.

How the fuck is PHP’s trim in Python? (click submit)

If the relationship has already been stablished on the database, we present the answer to the user:

PHP’s trim in Python is called strip. (a link to Python’s manual page on strip would be nice)

If not, we can let the user make this relationship. If it’s not possible, say, Python doesn’t have an array_intersect_uassoc function on any module, we let the user type an implementation, wiki-style.

Web 2.0 baby, the users provide all the content, we make all the money.

And the website backend is simple. A list of programming language and its functions, and the relationship between functions/methods, and somekind of wiki stuff to let people submit implementations.

I’ve been feeling lazy lately so go ahead and implement this if you want. Should be an useful tool.


Posted

in

by

Tags:

Comments

11 responses to “How the fuck is trim in Python?”

  1. yo Avatar
    yo

    *What* the fuck is trim in python.

    or

    How the fuck *do you* trim in python.

  2. Dave Avatar

    “How the fuck” should be “What the fuck”.

    Really it should just be “What”.

  3. inerte Avatar
    inerte

    Thanks yo (and Dave).

    10 years of almost daily english usage and I am still learning :p

  4. Lucas Avatar

    Às vezes parece que sou o único brasileiro que usa o HN 🙂 bom ver que não sou…

    Aliás, boa idéia. Eu nunca fiz nada muito grandioso, acho que vou tentar fazer uma implementação disso aí!

  5. inerte Avatar
    inerte

    Ae Lucas, bom ver outro brasileiro lá também.

    Manda bala rapaz. Sinceramente eu acho que daria um belo site, e a implementação não é difícil, nada de grandioso 🙂 Vai ser simples e útil.

    Eu só não faço mesmo pois, não é bem preguiça, mas estou já com projetos paralelos o suficiente para me manter ocupado por muito tempo 🙂 Fazer o sistema em si é até divertido, agora ficar atualizando com as funções é um pé no saco. Eu já tenho um tanto de sites que tenho de ficar atualizando, não queria mais um!

    Se/quando você fizer, avisa que eu dou uma olhada.

  6. Dat Chu Avatar
    Dat Chu

    Apparently you have not seen Matlab function list.

  7. Alin Hanghiuc Avatar
    Alin Hanghiuc

    I think the following is better:

    “What, in the name of God, is the equivalent of PHP's trim function in Python?!” 😀

    I think the idea of a site like this is truly awesome. The name is even “awesomer”, even if it's not correctly written since a good site needs a name with a twist.

  8. Alin Hanghiuc Avatar
    Alin Hanghiuc

    On second thought, the “What the fuck is trim in Python” name already has a couple of twists (it's an abbreviation of a cool name), so maybe there's no need for a mistake in it. And you could replace the profanity, “fuck”, with a “semi-profanity”, “frack”, which should become cool now that Battlestar Galactica ends and enters history. Unless the Caprica spinoff actually happens, in which case the coolness of “frack” will be delayed a few years. Unless Caprica sucks, in which case “frack” will never be cool. But I digress…

    Anyway, this reminds me of an old Romanian saying that goes something like this: Alright! We've got a horseshoe (the idea for the site, and a cool name for it). All we need is three more horseshoes, a wagon and a horse (the actual website, the users and the content)! 🙂

  9. inerte Avatar
    inerte

    Heh, one of my previous posts (in portuguese) talks about how ideas are useless in business, what really counts are the processes and the implementation. Most likely any idea will morph several times before reaching a level that its users will enjoy.

    On the other hand, rapid iteration and prototyping is really easy on the web. The seed is there, a simple tool telling you how to do something on a programming language based on what you know from another programming language.

    I've said to Lucas (in a comment below) why I am not going to implement this website. I am not just “feeling lazy”, but I have a couple projects that I am devoting my energy. Curiously, they're being written in Python. I had the HTFITIP idea a couple months ago, but never got around about getting serious to launch because I _think_ I am currently envolved in stuff more cool.

    I might be wrong, and HTFITIP could be a huge success (as huge as something cattered to newbie programming language polyglots can be), but it's not that I don't believe in its chances. It's that when I open the text editor I feel more motivated in working on these other two projects 🙂

  10. Mapping concepts from one programming language to another….

    I read through an article today that suggested an idea for a Web site where a user can specify a task in a programming language they know, and the site tells them how to perform it in some other language.
    This is an interesting idea, and no doubt co…

  11. Chucho Avatar
    Chucho

    This already exists. PHP to Ruby. I can see Web developers searching for equivalents in Ruby, but Python, I don't think so. Maybe Sys Admins, if they are not already using it as a scripting tool.