Re: [Python-Dev] syntactic support for sets

2006-02-06 Thread Alex Martelli
On 2/6/06, Guido van Rossum <[EMAIL PROTECTED]> wrote: > On 2/6/06, Donovan Baarda <[EMAIL PROTECTED]> wrote: > > yeah... the problem is differentiating the empty set from an empty dict. > > The only alternative that occured to me was the not-so-nice and > > not-backwards-compatible "{:}" for an em

Re: [Python-Dev] syntactic support for sets

2006-02-06 Thread Josiah Carlson
Donovan Baarda <[EMAIL PROTECTED]> wrote: > > On Fri, 2006-02-03 at 11:56 -0800, Josiah Carlson wrote: > > Along the lines of "not every x line function should be a builtin", "not > > every builtin should have syntax". I think that sets have particular > > uses, but I don't believe those uses ar

Re: [Python-Dev] syntactic support for sets

2006-02-06 Thread Guido van Rossum
On 2/6/06, Donovan Baarda <[EMAIL PROTECTED]> wrote: > yeah... the problem is differentiating the empty set from an empty dict. > The only alternative that occured to me was the not-so-nice and > not-backwards-compatible "{:}" for an empty dict and "{}" for an empty > set. How about spelling the e

Re: [Python-Dev] syntactic support for sets

2006-02-06 Thread Donovan Baarda
On Mon, 2006-02-06 at 15:36 +0100, Ronald Oussoren wrote: > On Monday, February 06, 2006, at 03:12PM, Donovan Baarda <[EMAIL PROTECTED]> > wrote: > > >On Fri, 2006-02-03 at 20:02 +0100, "Martin v. Löwis" wrote: > >> Donovan Baarda wrote: > >> > Before set() the standard way to do them was to use

Re: [Python-Dev] syntactic support for sets

2006-02-06 Thread Ronald Oussoren
On Monday, February 06, 2006, at 03:12PM, Donovan Baarda <[EMAIL PROTECTED]> wrote: >On Fri, 2006-02-03 at 20:02 +0100, "Martin v. Löwis" wrote: >> Donovan Baarda wrote: >> > Before set() the standard way to do them was to use dicts with None >> > Values... to me the "{1,2,3}" syntax would have

Re: [Python-Dev] syntactic support for sets

2006-02-06 Thread Donovan Baarda
On Fri, 2006-02-03 at 20:02 +0100, "Martin v. Löwis" wrote: > Donovan Baarda wrote: > > Before set() the standard way to do them was to use dicts with None > > Values... to me the "{1,2,3}" syntax would have been a logical extension > > of the "a set is a dict with no values, only keys" mindset. I

Re: [Python-Dev] syntactic support for sets

2006-02-06 Thread Donovan Baarda
On Fri, 2006-02-03 at 11:56 -0800, Josiah Carlson wrote: > Donovan Baarda <[EMAIL PROTECTED]> wrote: [...] > > Nuff was a fairy... though I guess it depends on where you draw the > > line; should [1,2,3] be list(1,2,3)? > > Who is "Nuff"? fairynuff... :-) > Along the lines of "not every x line f

Re: [Python-Dev] syntactic support for sets

2006-02-03 Thread Greg Wilson
> > > Raymond: > > > Accordingly,Guido rejected the braced notation for set comprehensions. > > > See: http://www.python.org/peps/pep-0218.html > > Greg: > > "...however, the issue could be revisited for Python 3000 (see PEP 3000)." > > So I'm only 1994 years early ;-) > Alex: > Don't be such a

Re: [Python-Dev] syntactic support for sets

2006-02-03 Thread Josiah Carlson
Donovan Baarda <[EMAIL PROTECTED]> wrote: > > On Fri, 2006-02-03 at 09:00 -0800, Josiah Carlson wrote: > [...] > > Sets are tacked on. That's why you need to use 'import sets' to get to > > them, in a similar fashion that you need to use 'import array' to get > > access to C-like arrays. > > No

Re: [Python-Dev] syntactic support for sets

2006-02-03 Thread Martin v. Löwis
Donovan Baarda wrote: > Before set() the standard way to do them was to use dicts with None > Values... to me the "{1,2,3}" syntax would have been a logical extension > of the "a set is a dict with no values, only keys" mindset. I don't know > why it wasn't done this way in the first place, though

Re: [Python-Dev] syntactic support for sets

2006-02-03 Thread Donovan Baarda
On Fri, 2006-02-03 at 09:00 -0800, Josiah Carlson wrote: [...] > Sets are tacked on. That's why you need to use 'import sets' to get to > them, in a similar fashion that you need to use 'import array' to get > access to C-like arrays. No you don't; $ python Python 2.4.1 (#2, Mar 30 2005, 21:51:1

Re: [Python-Dev] syntactic support for sets

2006-02-03 Thread Josiah Carlson
Donovan Baarda <[EMAIL PROTECTED]> wrote: > > On Wed, 2006-02-01 at 13:55 -0500, Greg Wilson wrote: > > Hi, > > > > I have a student who may be interested in adding syntactic support for > > sets to Python, so that: > > > > x = {1, 2, 3, 4, 5} > > > > and: > > > > y = {z for z in x if

Re: [Python-Dev] syntactic support for sets

2006-02-03 Thread Donovan Baarda
On Fri, 2006-02-03 at 12:04 +, Donovan Baarda wrote: > On Wed, 2006-02-01 at 13:55 -0500, Greg Wilson wrote: [...] > Personally I'd like this. currently the "set(...)" syntax makes sets > feel tacked on compared to tuples, lists, dicts, and strings which have > nice built in syntax support. Ma

Re: [Python-Dev] syntactic support for sets

2006-02-03 Thread Fredrik Lundh
Donovan Baarda wrote: > For Python 3000 you could extend this approach to lists and dicts; > [1,2,3] is a list, f[1,2,3] is a "frozen list" or tuple, {1:'a',2:'b'} > is a dict, f{1:'a',2:'b'} is a "frozen dict" which can be used as a key > in other dicts... etc. Traceback (most recent call last):

Re: [Python-Dev] syntactic support for sets

2006-02-03 Thread Donovan Baarda
On Wed, 2006-02-01 at 13:55 -0500, Greg Wilson wrote: > Hi, > > I have a student who may be interested in adding syntactic support for > sets to Python, so that: > > x = {1, 2, 3, 4, 5} > > and: > > y = {z for z in x if (z % 2)} Personally I'd like this. currently the "set(...)" synta

Re: [Python-Dev] syntactic support for sets

2006-02-02 Thread Alex Martelli
On 2/1/06, Greg Wilson <[EMAIL PROTECTED]> wrote: > > Generator expressions make syntactic support irrelevant: > > Not when you're teaching the language to undergraduates: I haven't > actually done the study yet (though I may this summer), but I'm willing to > bet that allowing "math" notation for

Re: [Python-Dev] syntactic support for sets

2006-02-02 Thread John J Lee
On Wed, 1 Feb 2006, Greg Wilson wrote: [...] > (Imagine having to write "list(1, 2, 3, 4, 5)"...) [...] I believe that was actually proposed on this list for Python 3. John ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailma

Re: [Python-Dev] syntactic support for sets

2006-02-02 Thread John J Lee
On Wed, 1 Feb 2006, Greg Wilson wrote: >> Like many things in Python where people pre-emptively believe one thing >> or another, the interpreter's corrective feedback is immediate: > > Yup, that's the theory; it's a shame practice is different. So what mistake(s) *do* your students make? As peop

Re: [Python-Dev] syntactic support for sets

2006-02-02 Thread Greg Wilson
> Like many things in Python where people pre-emptively believe one thing > or another, the interpreter's corrective feedback is immediate: Yup, that's the theory; it's a shame practice is different. > Once the students have progressed beyond academic finger drills and have > started writing real

Re: [Python-Dev] syntactic support for sets

2006-02-02 Thread Greg Wilson
> The PEP records that Tim argued for leaving the extra parentheses. What > would you do with {'title'} -- create a four element set consisting of > letters or a single element set consisting of a string? This is a moderately-fertile source of bugs for newcomers: judging from the number of student

Re: [Python-Dev] syntactic support for sets

2006-02-02 Thread Greg Wilson
> Generator expressions make syntactic support irrelevant: Not when you're teaching the language to undergraduates: I haven't actually done the study yet (though I may this summer), but I'm willing to bet that allowing "math" notation for sets will more than double their use. (Imagine having to w

Re: [Python-Dev] syntactic support for sets

2006-02-01 Thread David Wilson
On Wed, Feb 01, 2006 at 03:03:22PM -0500, Phillip J. Eby wrote: > The only case that looks slightly less than optimal is: > > set((1, 2, 3, 4, 5)) > > But I'm not sure that it warrants a special syntax just to get rid of the > extra (). In any case I don't think it's possible to differenti

Re: [Python-Dev] syntactic support for sets

2006-02-01 Thread Raymond Hettinger
[Greg Wilson] > This is a moderately-fertile source of bugs for newcomers: judging from > the number of students who come into my office with code that they think > ought to work, but doesn't, most people believe that: > >set(1, 2, 3) Like many things in Python where people pre-emptively beli

Re: [Python-Dev] syntactic support for sets

2006-02-01 Thread Steven Bethard
Raymond Hettinger wrote: > [Phillip J. Eby] > > The only case that looks slightly less than optimal is: > > > >set((1, 2, 3, 4, 5)) > > > > But I'm not sure that it warrants a special syntax just to get rid of the > > extra (). > > The PEP records that Tim argued for leaving the extra parenthes

Re: [Python-Dev] syntactic support for sets

2006-02-01 Thread Raymond Hettinger
[Phillip J. Eby] > The only case that looks slightly less than optimal is: > >set((1, 2, 3, 4, 5)) > > But I'm not sure that it warrants a special syntax just to get rid of the > extra (). The PEP records that Tim argued for leaving the extra parentheses. What would you do with {'title'} -- cr

Re: [Python-Dev] syntactic support for sets

2006-02-01 Thread Phillip J. Eby
At 01:55 PM 2/1/2006 -0500, Greg Wilson wrote: >I have a student who may be interested in adding syntactic support for >sets to Python, so that: > > x = {1, 2, 3, 4, 5} > >and: > > y = {z for z in x if (z % 2)} > >would be legal. There are of course issues (what's the syntax for a >frozen

Re: [Python-Dev] syntactic support for sets

2006-02-01 Thread Raymond Hettinger
[Greg Wilson] > I have a student who may be interested in adding syntactic support for > sets to Python, so that: > >x = {1, 2, 3, 4, 5} > > and: > >y = {z for z in x if (z % 2)} > > would be legal. There are of course issues (what's the syntax for a > frozen set? for the empty set?),

Re: [Python-Dev] syntactic support for sets

2006-02-01 Thread Brett Cannon
On 2/1/06, Greg Wilson <[EMAIL PROTECTED]> wrote: > Hi, > > I have a student who may be interested in adding syntactic support for > sets to Python, so that: > > x = {1, 2, 3, 4, 5} > > and: > > y = {z for z in x if (z % 2)} > > would be legal. There are of course issues (what's the syntax

[Python-Dev] syntactic support for sets

2006-02-01 Thread Greg Wilson
Hi, I have a student who may be interested in adding syntactic support for sets to Python, so that: x = {1, 2, 3, 4, 5} and: y = {z for z in x if (z % 2)} would be legal. There are of course issues (what's the syntax for a frozen set? for the empty set?), but before he even starts, I'