[Python-ideas] Predicate Sets

Georg Brandl g.brandl at gmx.net
Mon Jan 20 20:05:03 CET 2014


Am 20.01.2014 08:56, schrieb Andrew Barnert:
> From: Daniel da Silva <var.mail.daniel at gmail.com> Sent: Sunday, January 19,
> 2014 3:41 PM
> 
> 
>> Overview: Sets in mathematics can be defined by a list of elements without
>> repetitions, and alternatively by a predicate (function) that determines
>> inclusion.
> 
> The whole point of modern set theory is that sets cannot be defined by a
> predicate alone; only by a predicate _and a set to apply it over_. Which we
> already have in set comprehensions.
> 
> And your suggestion has the exact same problem that naive set theory had:
> 
> >>> myset = predicateset(lambda s: s.startswith('a'))
> >>> 'xyz' in myset
> False
> 
> >>> russellset = predicateset(lambda s: s not in s)
> >>> russellset in russelset
> 
> Presumably this should cause the computer to scream "DOES NOT COMPUTE!" and
> blow up...

I think it will just raise a NameError...

SCNR,
Georg



More information about the Python-ideas mailing list