R.Brodie at rl.ac.uk
Tue Oct 17 15:39:39 CEST 2006
"abcd" <codecraig at gmail.com> wrote in message
news:1161091832.088769.279630 at b28g2000cwb.googlegroups.com...
>x = None
> result = (x is None and "" or str(x))
> ...what's wrong with the first operation I did with x? I was expecting
> "result" to be an empty string, not the str value of None.
Your evil tertiary hack has failed you because the empty string
counts as false in a boolean context. Please learn to love the
new conditional expression syntax:
More information about the Python-list