July 8th, 2008
Python doesn’t know the trinary operator “?:” from C. However, it’s pretty easy to emulate:
x ? y : z --> [z, y][bool(x)]
(If you’re sure that x is already a boolean type (or an integer of value 0 or 1), you can omit the bool() function, of course.)
How does the trick work?
We simply create a small list constant, containing the two values to choose from, and use the boolean as an index into the list. “False” is equivalent to 0 and will select the first element, while “True” is equivalent to 1 and will select the second one.
Note that always all three operands will be evaluated, unlike the “?:” operator in C. If you need shortcut evaluation, use an if-else statement.
Actually, there’s another way to do it with shortcut evaluation, but it only works if y does not contain a boolean False equivalent:
x ? y : z --> bool(x) and y or z
July 3rd, 2008
Microsoft is seeking partners including Time Warner and News Corp. in a new bid to acquire Yahoo’s search business, the Wall Street Journal reported on Wednesday.
Microsoft wants to acquire Yahoo search, with the partner, likely a media company, taking the rest of Yahoo’s business. CEO Steve Ballmer called Yahoo Chairman Roy Bostock and arranged a meeting set for Monday, but that meeting was cancelled, the Journal reported, citing people familiar with the situation.
Microsoft officials contacted in London had no comment Wednesday morning.
As I reported in January, Microsoft made an unsolicited bid to buy all of Yahoo, an offer the latter refused. Although Microsoft later raised its offer price, Yahoo continued to decline, and in early May, Microsoft ended the negotiations.
On Monday, his final day as Microsoft’s chairman, Bill Gates stated that he thought any deal between his company and Yahoo was unlikely.
However, the matter has refused to go away with Microsoft indicating it would still be interested in buying part of Yahoo, namely its search business. At the same time, Yahoo investor Carl Icahn has pushed for a deal with Microsoft. He has stated publicly on several occasions that the company’s board failed to serve shareholder interests by refusing to sell, and is maneuvering to replace the board at an upcoming investor meeting in August.