How the fuck is trim in Python?
inerciasensorial.com.br
inerciasensorial.com.br
"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.
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?
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.
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.
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".
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.
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.
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.
I think I'm done now talking about swearing on Hacker News.
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.
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.
Sorry if that sounds dickish, but this is really the last place any of us should be concerned about children reading, specifically your children.
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 ___?"
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.
Edit: Grammar
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.
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...
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.
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).
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
http://www.python.org/about http://www.google.com/search?q=python+"batteries+included"
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)
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.
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
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.
I've started on a modern RHEL / Ubuntu / Powershell Rosetta Stone in my own time. Let me know if you want to see it.
Is anyone interested in working on this as an open source side project with me? My preferred stack is Python, Django, Appengine, and jQuery.
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.
what's the url?
There's no such site now. He wants someone to write this because he thinks it will be useful
too much sex in holland (fat in usa)