Implicit conversion to boolean in if and while statements

Chris Angelico rosuav at gmail.com
Mon Feb 11 13:40:23 CET 2013


On Mon, Feb 11, 2013 at 11:18 PM, Rick Johnson
<rantingrickjohnson at gmail.com> wrote:
> On Sunday, February 10, 2013 5:37:46 AM UTC-6, Steven D'Aprano wrote:
>> Rick Johnson wrote:
>> > IMO "Set Types" should only exists as a concequence of "freezing" an
>> > array,
>>
>> Sets are not frozen lists.
>
> Indeed. That wording was a bit clumsy on my part.
>
>> > and should have NO literal syntax available.
>
> I may have spoken too soon on this issue. My reasoning for /not/ having a literal set syntax was due to symbol congestion, however as i described in another post, the problem can be solved by literally "type declaring" the literal.

Or doing what you were pointing and laughing at Pike for, and using
two-symbol delimiters. You could even make it majorly logical:

list_ = [[ 1, 2, 3 ]]
tuple_ = ([ 1, 2, 3 ])
dict_ = [{ 1, 2, 3 }]
frozendict_ = ({ 1, 2, 3 })
set_ = [< 1, 2, 3 >]
frozenset_ = (< 1, 2, 3 >)

I'm not actually sure where I stand on that argument. Some of those
types are distinctly unusual (when would you use frozendict?), and may
well not need literal notation. But it is nice to have them all.

ChrisA



More information about the Python-list mailing list