ways to declare empty set variable

Ben Finney bignose+hates-spam at benfinney.id.au
Tue Feb 12 16:34:38 EST 2008


"Sun" <as at hut.at> writes:

> I was wondering why can't I use a format as "var = {} " to
> "var=list()" in set variable, and decided not to bother with it.

Python 3.0 will gain syntax to specify a literal of type 'set'
<URL:http://www.python.org/dev/peps/pep-3100/>::

    >>> {17, "foo", 12.5}
    set([17, 'foo', 12.5])

but this won't allow you to declare an empty set literal, because
that's already easy with 'set()', and '{}' is taken already for an
empty dict literal.

-- 
 \     “Unix is an operating system, OS/2 is half an operating system, |
  `\           Windows is a shell, and DOS is a boot partition virus.” |
_o__)                                                 —Peter H. Coffin |
Ben Finney



More information about the Python-list mailing list