[Python-3000] Set literal

Barry Warsaw barry at python.org
Fri Jan 25 01:23:57 CET 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Jan 24, 2008, at 7:12 PM, Raymond Hettinger wrote:

>> Looking over the code base, frozensets are used rarely.
>> So I don't think this is warranted.
>
> There is no shortage for perfect use cases in the form:
>
>   if urlext in {'html', 'xml', 'php'}:

It's interesting that you point this out because I've had debates with  
people about the difference between:

     if urlext in ['html', 'xml', 'php']:

and

     if urlext in ('html', 'xml', 'php'):

I generally prefer the latter but I know folks who prefer the former.   
What's interesting is that in both cases we're trying to ask if the  
key is a member of a literal set, and to me, it makes no sense for  
that literal to be mutable.  So I also think Raymond's idea has merit.

- -Barry

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)

iQCVAwUBR5ksHnEjvBPtnXfVAQJkCAP9Fe/3gp9Ar6bKmCEq9f6uwUdxjwvfpRdI
7hOhwU7u2/bCTfVv/bxYi6SYIs54xzBPruHxiQ5qNwduRPMTeDHcKfSw1XrByVip
uNvjzF4ul+hplYeetKYylDDJbBxUqHXRT27psHRluNRorr9dkcqjI73zxj4FdM9M
BCwXJfW/9hI=
=dYZQ
-----END PGP SIGNATURE-----


More information about the Python-3000 mailing list