[Python-Dev] Re: PEP 218 (sets); moving set.py to Lib

Tim Peters tim.one@comcast.net
Thu, 22 Aug 2002 01:38:22 -0400


[Raymond Hettinger]
> FTI, ISETL uses '+' and '*' as synonyms for the spelled-out
> 'inter' and 'union' operators.

You realize that reads as if they used '+' for 'inter' and '*' for 'union',
right?

> Playing with a sample session for possible inclusion in the
> tutorial, I've found that '|' is not nearly as clear in its intention
> as '+'.
>
>...
> engineers = Set(['John', 'Jane', 'Jack', 'Janice'])
> programmers = Set(['Jack', 'Sam', 'Susan', 'Janice'])
> management = Set(['Jane', 'Jack', 'Susan', 'Zack'])
>
> employees = engineers | programmers | management    # more clear with '+'

I haven't made time to play with the new sets module yet, but it was
instantly clear to me just as it was.  I think Guido makes a very good point
about "+" making it much more confusable with a sequence or numeric
operation too.  OTOH, I'm rarely a fan of overloaded operators, and suspect
I'll tend to use whatever .method() names the module supports (the set
modules I've written for my own use never overloaded operators, btw).

One thing did strike me as odd later!  If I were to ask this company's HR
director what kinds of employees they had, I bet the answer I'd hear is

    well, mostly we have engineers and programmers and management

It seems far less likely I'd hear

    well, mostly we have engineers or programmers or management

and I read "|" as "or".  If I heard

    well, mostly we have engineers vertical-bar programmers
                                   vertical-bar management

I'd beg to work there for free <wink>.