As we know,
{} # Represents a dict
And
{'one': 1} # Again a dict
How and why is this a set :
{'one', 'two', 'three', 'four'} # I thought it should give syntax error
But it gives :
set(['one', 'two', 'three', 'four']) # Strange ?? [ Should this happen ? ]
Can you provide a link to some official doc discussing the same ?
Set literals are a 3.x feature that has been backported into 2.7.
This is a useful feature - note that set comprehensions are also allowed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With