Hacker News new | past | comments | ask | show | jobs | submit login
How the fuck is trim in Python? (inerciasensorial.com.br)
57 points by inerte on Jan 23, 2009 | hide | past | favorite | 71 comments



"How the fuck is..." is the wrong wording, at least in idiomatic American English.

"What the fuck" (aka "WTF?") connotes more "this is wrong/surprising" than "could you please tell me the answer?". "WTF?" is often a rhetorical question, but even when it demands a response, the response is a situational explanation, not a mere bit of trivia (such as "trim is called strip").

"What the fuck is trim doing in Python?" is more idiomatic in its use of 'fuck', but would express surprise that Python has a trim() function, as if it were against the spirit of the language. Because your "How the fuck..." sounds a little like that in its use of 'fuck', it gives the wrong impression for what you're trying to achieve. (Clicking your link, I expected a rant, not a idea for a equivalence-lookup service.)

To express curiosity about the right answer -- "what is the equivalent of trim in Python?" -- but with the same sort of irreverence possible via 'swear' words, a more likely wording from a native speaker would be "how the hell do you do trim in Python?"

"How the hell" expresses exasperation but also suggests some genuine interest in a 'right' answer. (You sometimes see "how the fuck do I..." or "how the fuck do you..." also, but anything starting "how the fuck" is far less common than either "how the hell" or "what the fuck".)

In general, using 'fuck' casually can be a problem, for a number of reasons. I believe the primary reason is that it is distracting -- it claims that the containing statement is emotionally important and demands special attention.

Is a simple cross-programming-language lookup facility emotionally important? No.

So some people will act 'offended' at use of a word with other 'naughty/private' connotations, and even some people who like to swear will feel like you've diluted the word's value.

You need to save 'fuck' for really important uses, or it won't have any fucking meaning left at all.


I hope there's no problem submitting my own blog post. I've been thinking about making a website like the one I described on the post for a long time but never got up and did it.

Anyway, I also hope the "fuck" up there isn't too offensive. I don't live in the USA (and english isn't my primary language), and while it seems people use this word every minute of their lives, on written material (and social contexts) of the web is rarely seen, so I don't quite grasp the ethic relationship of daily english and the internet.

If you could read my mind (in portuguese) and see what I really think when I am trying to remember how trim is named in Python, worse profanities would appear anyway :)

Oh, and I don't know if this is "HN material". I've complained about some articles that appeared here, blog posts without much content at least. But I've also seen worse stuff live longer on the main page, so I thought, what better way to see if what I wrote would survive than just submitting it?


Ah, I wondered what nationality you were. (I'm Portuguese too, but not natively.)

Fuck is a bit strong for this type of article. Also, rather than saying 'how the fuck', we would say, at least in American English, "what the fuck is 'trim' in Python?" or even more clearly, "what the fuck is PHP's trim in Python?"

But yeah, I have the same problem when moving through languages. I know the concept, but I have to read through the docs to find out the exact function syntax.


I appreciate your remark on this post.

In general I have to say I am sick of people using the "F" word so lightly on this forum. I have an 11 years old very curious daughter that I adore, she get on my laptop all the time and is very interested in what I do. I have been very concern about what will happen if she sees that I’m reading stuff with such language in it. We should all do something about this.

Demod me if you want but this is a real problem from the concern parent that I am.


You could teach her that "fuck" is a good word to express a specific emotion. Using it all the time risks other people thinking she is vulgar. Using it at just the right moment can be very effective in conveying her thinking.

I have a new daughter, and this is the approach I'm going to try. We'll try to convey that there are no bad words, per se -- only more or less appropriate times to use words. We'll also point out others' likely reactions.

I still remember how in University a friend of mine who "never" swore got everyone to pay attention when she finally did say "fuck".


Which specific emotion does "fuck" express? It seems to me like the word doesn't really express a specific emotion, rather tends to add some vague sense of anger to whatever else you were trying to express.


True. The "specific emotion" bit seems like nonsense, in retrospect. I guess it would be more accurate to say that "fuck" can be an effective way to convey sharp emphasis, or the vague frustration you mentioned.


Mine are 9 and 7. If your 11 year old isn't already using the word "fuck", I would be concerned about social norms. The fact is, the Internet is a big scary place, and Hacker News is the very least of the problem, so let's not bother addressing this issue.


I agree. Eleven years old is ~6th grade; she probably hears words like "fuck" on a regular basis at school.

The only logical arguments I've heard for not letting kids swear are:

- It's against the social norm (it'll get them in trouble)

- It lessens the words' value.

Since kids invariably will encounter swear words at some point, trying to shield them is pretty hopeless. The best solution is to mitigate the two problems above; teach them when they shouldn't swear (mainly in front of adults) and not to swear like a sixth-grader ("Hey, man, what the fuck are you doing today? Shit, I've got a fuckton of goddamn homework.")

Swearing at people is another thing entirely, though.


It’s funny to see folks thinking of raisin kids like a writing an algorithm. Let me tell you that the role model thing is not a vain and empty factor you raising children. They must trust you and look at you as a last resort, they know things are bad out there they expect home to be a safe place; you should do your best to provide that to them.


I don't disagree. You should definitely be a good role model to your kids; in fact, I feel that I hold parents to a higher standard than most. I just fail to see how letting your kids see the word "fuck" is intrinsically bad for them.


Duly noted.


I got hauled into the Principal's office in grade 4 or 5 for yelling "SHIT!" in the playground. The Principal asked what my parents would think when they found out that I'd been swearing. I told him that they wouldn't mind, since it was appropriate in the circumstances. He let me go.


Our policy is similar. Erin and I don't avoid swearing at home ourselves, but the kids are strictly forbidden from swearing. It's not about the words themselves (I see no moral issue with swearing), but rather about discipline and respect; this is a simple bright-line boundary.


For what it's worth, I've had good results with the opposite approach. My daughter (now 7) has been allowed to curse as long as she's been allowed to talk.

That said, there are boundaries that she understands clearly -- she's not allowed to use curse words at school, for the same reasons I choose not to swear at work. She knows and understands that it isn't an appropriate place to use foul language. At home, she's free to use whatever language crosses her mind.

She is also not allowed to curse AT people anywhere, because it's mean.

She's a smart, responsible, well adjusted child who rarely uses foul language. Occasionally we'll hear something like "I can't figure out how to work this damn thing," when playing on the Wii, but she doesn't run around like a Tourette's sufferer either.


My daughter is 6 now and we approach her swearing EXACTLY the same way that you do. She is in 2nd grade now and knows that swearing is not appropriate at school. She also knows that it isn't appropriate at certain relatives' houses (one set of grandparents; at the other set, it's ok). At some relatives' places, it's perfectly ok. At some of her friends' houses it's no problem; at others' it would not go over well. Stephy (my daughter) knows that swearing is entirely and completely acceptable at home at all times, so she exercises that right with a full range of expletives, without punishment, at home. She has learned where it is appropriate and where it isn't from growing up with it from day one of learning to speak.So-called "swear words" have always just been normal words for her, with a healthy sprinkling of knowing when and where to use them properly (for example, she knows, even at home, that it isn't acceptable to swear AT someone; that is literally her only limitation on it. But "conversational swearing" is perfectly fine and normal at home all the time). She has never crossed the line or been inappropriate, and I don't suspect that she ever will. She is growing up with a full range of colorful words at her disposal, but also with the intelligence to know when to use them. To us, that is the way it should be and we are perfectly content with letting her swear to her heart's content anytime she wants at home.


You trust your daughter more than I trust mine. =)


The beautiful mystery of parenting is that neither of us really knows if we're right, and we might not ever.

I'm not saying that my way is the right way. It might be, and I suspect that it is for my daughter, but I don't know you or your family. The premise for my ideology focuses around 2 things: 1) I don't want to be a hypocrite. I curse all the time, and while I'm mindful of my tongue in professional / social interactions, I do use foul language, and 2) I was more worried about banishing expletives making them into a forbidden fruit.


I am not a parent, so I'll admit a skewed perspective here, or perhaps a lack of context entirely, but I think you need to be very careful about putting forth authority -- what I assume you mean as discipline and respect -- as a sufficient basis for different standards of behavior.

From watching people grow up in my generation under the same sort of philosophy, I've seen them develop the mind set that anything put forth by authority must be correct, and in the process hold obviously contrary points of view without batting an eye. One of the causes I've been able to gather is that they spent a large part of their growing years being told how things are and to accept that as sufficient evidence, but not having what is asserted jive with their own impressions. Enough of that, if they don't rebel they develop the sense that their own impressions and intuitions are completely flawed, and should never be trusted without someone else to tell how things are.

I'm not saying that you are wrong to enforce a no swearing policy with your kids -- that's an entirely different discussion that you have already said you don't want, so I won't push for it. But from my teenage perspective of not so many years ago, I can imagine being very different -- less curious, less assertive, less independent -- if my parents had been more authoritarian, and not to be harsh but less reasonable, approach to setting ground rules for my behavior.


I understand where you're coming from, but if you knew me better (or, I imagine, any parent that writes on HN), you'd know that isn't an issue in this case. And, there's a difference between thinking for yourself and growing up incapable of recognizing boundaries.


I've gathered from enough people that being a parent runs a moderate likelihood of changing my perspective on this; time will tell. And I also wasn't presuming on your capabilities as a parent, or anything else about you; just on the argument you laid out here. :-)

And I agree, there is a difference between thinking for oneself and learning about boundaries. Except that I could imagine my 10-12 year old self wondering why my primary role models seemed to be demanding one form of behavior, and then exemplifying a different form. At this point, I could only imagine thinking a boundary had been placed on where I was allowed to think for myself. They'd seem like boundaries for the sake of having boundaries. Maybe you see it differently or don't care what I think, but I'm still confused.


Respect goes both ways, if you expect some you should start by giving.


My kids are expected to respect my judgement and authority, in that they are kids and I am an adult. I am expected to respect many things about them, but their authority is not among them. I am also allowed to stay up really late, a privilege that is also not reciprocal.

I think I'm done now talking about swearing on Hacker News.


If I was 11 and discovered that "trim" was called "strip" in Python, I'd have observed it as curious and gone back to programming. I wouldn't have been frustrated and the idea to get angry about it wouldn't have even occurred to me.


I’m far from being an expert on this, so take it easy from a fellow parent. There’s a huge difference about you reading or using profanity near you child than him/her hearing it on TV or reading on the internet.


If my son is reading over my shoulder, the bad language I'm really worried about him picking up is Perl.


Thanks for that - I just got a room full of odd looks for my audible outburst when I read that line!


Don't forget to tip your waiter.


I agree. At 11, I would be concerned if my child WASN'T swearing! It's now normal for an 11 year old to be using the word "FUCK" alot, so I would wonder about one who wasn't saying that on a regular basis instead of worrying about it if he/she was. Let kids cuss! They qare going to eventually anyway.


If an 11 year old is using fuck I would be concerned about social norms. There's no reason to swear playing kickball.


You could install a greasemonkey profanity filter:

http://userscripts.org/scripts/show/4175


The word "fuck" won't hurt your daughter.


Cmon dude really? Should anyone on HN be concerned about your spawn? That's your job, not ours, and this isn't Dave and Busters.

Sorry if that sounds dickish, but this is really the last place any of us should be concerned about children reading, specifically your children.


.com.br - Brazil???


Yup


I think it's a really awesome idea. As others have pointed out, "what the fuck" is the right way to say it.

More common than that these days is "WTF" (the abbreviation). This allows you to get the same point across without using profanity. (Keep in mind that in some environments like schools or corporations, sites with profanity can get flagged and blocked.)

So maybe "WTF is ___ in ___?"


I gotta disagree about "what the fuck" being the right way to say it. I am not concerned about the rebellious nature of cursing, but I am bothered by using words that contribute so little to the meaning. I've heard arguments that they serve to express things in a more emotional manner. Like anything, they've been so over used that the emotional enhancement is diluted to simply being a socially rebellious expression.

Edit: On this topic, I think people, at some level, are aware of this. That's why it's not as commonly found in written word vs. spoken word.


The nice thing about it here is that it very effectively conveys the frustration that underlies the value proposition for the site.


At some level I would like to use this sort of site for the humor value. It not only sympathizes with me; it empathizes with me AND works to solve my problem - so long as it works right. If it doesn't I'd be adding a few more colorful words to the mix :-)

Edit: Grammar


Oh, I think what I meant was "how the fuck" was not idiomatic English, and that what he meant to say was "what the fuck." I more meant the "proper" way to say the phrase he was referring to.


Of course, if you didn't have this service, you'd have to RTFM.


Which means Read The Faq and Manual... :)


Among younger people and HN readers it's no big deal, but among other groups it's highly offensive: older, non-technical, professional, parents, probably women in general, etc. Obscenity can spice up writing, but in technical essays it makes the writing look unprofessional. I would hesitate to send a link to your site to a manager or woman that I did not know well.


The ___domain xsyinz.com is available...


While I don't give a fuck about your choice of words, I am unable to read the article as "Websense" blocked the website as pr0n coz of words in the URL :-(


I'm just tired of reading blog posts full of swearing. It's always the same bland content without nuances.

I'm sure that you could have written a better post, without resorting to swearing - or perhaps you belong to the Zed Shaw school of writing.


Apologies if this gets mentioned elsewhere, but I suspect you'll have trouble dealing with two functions in separate languages that do _almost_ the exact same thing, but differ in some tiny way that screws people up. Maybe they return different values on an error, one does it in-place while the other returns the new value, or even worse are the really tricky differences like what happens if certain variables are/aren't static.


I think a well timed & placed swear word adds some zing. As long as you're posts and titles aren't filled with them, you should be fine.


I think this is a great idea.

What the fuck is <Language>'s [some string] in <another Language>?

[some string] can even be common objects methods, like Array.splice

For each mapping, you should allow comments to fill in the specifics. For example, VB has "String.left()" and "String.right()", which can both be achieved in by PHP's substr() if you pass the right params. Boy.. am I going to be hated for the languages I just mentioned...


I don't hate you. I think pity or scorn would be more appropriate. ;)


Cool idea. There's already a similar site for PHP->Rails - http://railsforphp.com/ - would be great to have something that works for multiple languages.

My $0.02: Allow user annotation (ie, comments). Back when PHP was new, user comments on the function pages were very helpful for figuring out how to do stuff, what to avoid, known bugs etc. I often miss it when working with other languages.


That can be one of the most frustrating things about using a new language. Great idea, hope you can implement it yourself.


While the initial function mappings could be quite simple, I see the future of this being a bit like Google Translate for computer languages. We just need a Mechanical Turk wiki like process to get the longer snippets code translated. I used to work with ESRI ArcView software and its Avenue scripting language. When they changed their internal scripting to Visual Basic for Applications, there was a lot of work to be had translating scripts. (Now they support Python as a scripting language as well.) I wonder if for any given JVM language (Java, JRuby, Jython, etc.) you could write a decompiler for the bytecode that would take you back to a different source code language.


"How" seems like the wrong interrogative. Perhaps "Where the fuck is 'trim' in Python?"


One thing: what works for PHP isn't necessarily a good approach to learning another language, such as Python.

PHP's global space and the feel of "batteries included" is sharply contrasted to Python's typing and object oriented feel. Having people write PHP in Python would not only be counter-productive, the people being brought up on that style wouldn't get much out of python.

The trim example specifically: line = "foo\n" new = line.rstrip("\n")

vs. if we were to directly to transliterate from php, it would be string.rstrip(line,"\n")

(which is quite a different style)

This approach also under-emphasizes using language specific tools (e.g. interactive python, pydoc).


Typically the learning curve on a new language goes something like this.

1. Knows old language

2. Learns the syntax of new language

3. Writes old language style in new language

4. Through continued practice and learning in the new language, starts to pick up the idioms and styles of the new language.

5. Becomes fluent and well versed in the idioms, styles, advantages, and flaws of the new language. Can contrast old language with new language well and use the style most appropriate to the problem.

6. rinse and repeat

Not everyone progresses all the way through the process when they pick up a language. In fact I'd argue that some people never even pick up the idiomatic way of doing something in a language even if that is their only language.

I think you could think of this like an english-spanish dictionary. It's not going to teach you the idiomatic way of speaking, but it will give you the correct word to use. Which I would suggest is a milestone on the path to idiomatic speaking.

* edit for formatting


Sorry, but it's Python that uses the "batteries included" phrase.

http://www.python.org/about http://www.google.com/search?q=python+"batteries+included"


Ah, now I understand what you're getting at ...

Indeed, this is a great idea. Would love to see someone like Joel Spolsky implement this as part of StackOverflow.com.

I'd be interested in doing this in Rails ... if anyone wants to collab with me, let me know (email in profile)


I started a project like this once, but never finished. Contact me if you want my incomplete "Perl to Python phrasebook." My goal was to help unfortunate Perl programmers migrate to Python.

One thing to look out for: things that are functions in some languages are syntax in others, methods in others, and complicated recipes in others. You need to give people sample code. For example, look at how each language wants you to express "length of an array/list:"

Python: numbers = [4,8,15,16,23,42] print len(numbers) # yields 6

Perl: @numbers = (4,8,15,16,23,42); print $#numbers + 1; # yields 6 # or... $numlen = @numbers; print $numlen;

Not really a "function" at all in Perl.


Oh man, I was thinking the same thing. Mine was going to be something along the lines of 'phptopython', where I could half document, half make a site about converting php code to python, or how to do similar things. I wanted it because I found it didn't exist when I was trying to learn Python. I figured if I knew what it was in php, it'd be easier to work on.

Then, like yours, I figured a wiki would be good, and have each page dedicated to a code snippet, whether it is "using trim" or "finding the square root of a number".

Haven't got around to it though


Once you get past integers and strings I think you'd start hitting language and library limitations where things don't translate smoothly - the same core reason that the languages are usefully different in the first place.

Not at all web 2, but the PLEAC project ( http://pleac.sourceforge.net ) has been working on equivalent samples of code in different languages for a number of years.

These days I'd half expect it to be a crossbreed of Google Code and Google Translate.


He also asked if anyone was offended if he linked to his own site. I've been wondering myself. I have been considering submitting some issues for discussion in the form of a two or three paragraph statement backed by an essay elsewhere. Given that the topic is of general interest to HN and is not self-promotional spam, does it fit with the HN etiquette?


For operating systems, there's http://bhami.com/rosetta.html


That's vastly out of date - DGUX anyone?

I've started on a modern RHEL / Ubuntu / Powershell Rosetta Stone in my own time. Let me know if you want to see it.


This is a really good idea. Whenever I learn a new language, it is always a pain re-learning how to do common tasks.

Is anyone interested in working on this as an open source side project with me? My preferred stack is Python, Django, Appengine, and jQuery.


Google would give you the answer if you just type any such phrase.


Best quote in the article: "Web 2.0 baby, the users provide all the content, we make all the money."


OP here, I am watching this thread but not replying to anyone yet, but I want to clarify this phrase. It's not really mine (at least its meaning) but I couldn't find who said it first to give credit, since the words aren't exactly how I typed.

Anyway, it's something that has bugged me for some time. Lots of "web 2.0" companies think that users will come and start to post a lot of stuff, and the reality is that unless you can give them some kind of semi-instantaneous gratification, they'll never post anything.

Wish I could find who said it first. I think it captures a lot of the hype behind the web 2.0 buzzword.


can anyone else not find the link to the actual site. I can't. I tried http://HTFITIP.com

what's the url?


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

There's no such site now. He wants someone to write this because he thinks it will be useful


"how the fuck is trim in Python? It’s called strip by the way."

too much sex in holland (fat in usa)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: