Implicit conversion to boolean in if and while statements

Chris Angelico rosuav at gmail.com
Sat Feb 9 00:01:00 EST 2013


On Sat, Feb 9, 2013 at 12:29 PM, Ian Kelly <ian.g.kelly at gmail.com> wrote:
> On Fri, Feb 8, 2013 at 5:49 PM, Rick Johnson
> <rantingrickjohnson at gmail.com> wrote:
>> What the hell? Oh yeah, you must be using pike again. No, if it were pike the list would look like this:
>>
>> ({({"q"}), ({"w","e"}), ({"r","t","u"}), ({"i","o","p"})})
>>
>> Folks, i couldn't make this stuff up if i wanted to. Go read for yourself if want a few laughs.
>
> You didn't even do a good job of it.  Yes, Pike uses two characters
> instead of one to wrap array literals.  Big friggin' whoop.  On the
> minus side, it's a little more typing.  On the plus side, they stand
> out better, and you don't have the [] characters doing double duty
> denoting list literals and indexing alike.

Oh, is *THAT* what he meant. I had no idea why it was so laughable.

Another advantage of using two characters: There's no conflict between
set and dict literals. How do you notate an empty set in Python? {}
means an empty dict. In Pike, a mapping is ([]) and a multiset (you
can actually have duplicates, though I don't usually make use of that)
is (<>). But that's a pretty minor design decision, and I wouldn't
laugh at either for the choice. It's like choosing to paint your car
blue or red.

ChrisA



More information about the Python-list mailing list