News for hackers. Stuff that matters.
Re:The switch: Python to Node.js by epidemian on Sunday December 18, 2011 @11:28AM (#3366875)
Or methods like __init__, __str__, __cmp__, etc. I know they are part of Python's protocols, which are basically a form of the template method pattern, and that they do make sense. But to some people they feel hackish; they woud prefer to have "normal" name methods for these protocols instead.
Re:The switch: Python to Node.js by mixmastamyk on Sunday December 18, 2011 @07:16PM (#3367919)
If they were normal they'd eat up your namespace.
Re:The switch: Python to Node.js by epidemian on Sunday December 18, 2011 @08:00PM (#3368020)
Yes. But, it that a bad thing?

For example, I think if you'd have to explain how to change the string representation of some kind of object, saying "just define the 'str' method and then call it, like 'something.str()'" is simpler than "define a '__str__' method -- don't worry about all the underscores -- but then don't call it directly; instead of that, use the global 'str' function".

I don't know if that extra indirection (i.e. calling 'str', which, in turn, calls '__str__'; or 'next', that calls '__next__' in Python 3) adds more value than the simplicity of not having that extra indirection in the first place.

Re:The switch: Python to Node.js by Tobu on Monday December 19, 2011 @01:56AM (#3368770)
If it used normal names, Python couldn't evolve new methods for its protocols with language support. It would need some kind of annotation saying “yes I really mean to get this method called by the language and didn't just happen to use the same name by coincidence”.