News for hackers. Stuff that matters.
Re:The Day Python Embarassed Imperative Programming by kingkilr on Monday February 27, 2012 @08:25AM (#3638853)

  In Python, every object is an example of a monad. It has two possible values: None and anything_else.
Is no more true then, "It has two possible values: 'Hello, I am a sexy bear' and anything_else."
Re:The Day Python Embarassed Imperative Programming by klodolph on Monday February 27, 2012 @08:45AM (#3638923)
Why pull a quote out of context to nitpick it? The article goes on to explain how common it is to check if an object is None and act differently, which is what gives us the same monadic structure as the Maybe monad in Haskell.
Re:The Day Python Embarassed Imperative Programming by whateverer on Monday February 27, 2012 @09:27AM (#3639052)
Poorly worded, but the point is that every reference in Python, like in Java, ALGOL 60 and countless other languages, may be of a certain type, or point to None. In Haskell, save for a caveat[1], this doesn't happen, and you represent nullability (failure, usually) with types like Maybe or Either, when you want to. Those happen to be monads, too, but you can use them without the monadic operators.

[1] The caveat is the bottom value, which represents something akin to an exception which wasn't handled, that your program is now in an undefined state and now will promptly crash if you use the 'bad' part.

Re:The Day Python Embarassed Imperative Programming by icebraining on Monday February 27, 2012 @10:26AM (#3639257)
every reference in Python, like in Java, ALGOL 60 and countless other languages, may be of a certain type, or point to None.

Well, in Python every reference may be of any type. None is just another object, there's nothing particularly special about it.

Re:The Day Python Embarassed Imperative Programming by mikeash on Monday February 27, 2012 @10:23AM (#3639249)
Null is an interesting exception in languages with static typing such as Java. But there is no static typing in Python. Literally any variable can hold any value of any type. None is not nearly so special there, since you can also assign 3 to any variable, or the identity function, or a string containing the answer to the question of life, the universe, and everything.

In languages like Java, null has special semantics that no other value has. In Python, there's nothing particularly special about None, it's simply used as a convenient sentinel by convention. I could easily write Python code that returns the literal string "This value is empty" as the sentinel instead, something that doesn't apply to languages like Java.

Re:The Day Python Embarassed Imperative Programming by whateverer on Monday February 27, 2012 @10:47AM (#3639331)
Yes, actually, you are right. It's all the same in Python because the references can always point to any value, and None is just a value of the NoneType.

And due to Python's runtime types, it wouldn't matter either way, because even if None only existed within the context of a Maybe type, you could still just apply any operation on it and have crash at the first method call on it.

Re:The Day Python Embarassed Imperative Programming by SoftwareMaven on Monday February 27, 2012 @10:42AM (#3639310)
That's not completely accurate. None is still special in Python because it's the value chosen by the interpreter to represent an expression that doesn't explicitly return a value.

It is true that None is implemented like any other object (whther the value of 5 or an instance of my own class), but it still maintains special semantics.

Re:The Day Python Embarassed Imperative Programming by danieldk on Monday February 27, 2012 @08:53AM (#3638936)
Except that 'Hello, I am a sexy bear' is generally not used to indicate failure in Python, while None often is.

Edit: strange downvoting here :/. The parent has a point in the sense that None is just another object in Python. However, it's a singleton with a special meaning (by convention). Consequently, the parent used a false analogy.

Re:The Day Python Embarassed Imperative Programming by indiecore on Monday February 27, 2012 @08:39AM (#3638901)
Everything in life is 50/50, either it happens or it doesn't. The statistics industry is just trying to pull the wool over our eyes.

WAKE UP SHEEPLE.