• Guido van Rossum's avatar
    Change the binary operators |, &, ^, - to return NotImplemented rather · dc61cdf6
    Guido van Rossum yazdı
    than raising TypeError when the other argument is not a BaseSet.  This
    made it necessary to separate the implementation of e.g. __or__ from
    the union method; the latter should not return NotImplemented but
    raise TypeError.  This is accomplished by making union(self, other)
    return self|other, etc.; Python's binary operator machinery will raise
    TypeError.
    
    The idea behind this change is to allow other set implementations with
    an incompatible internal structure; these can provide union (etc.) with
    standard sets by implementing __ror__ etc.
    
    I wish I could do this for comparisons too, but the default comparison
    implementation allows comparing anything to anything else (returning
    false); we don't want that (at least the test suite makes sure
    e.g. Set()==42 raises TypeError).  That's probably fine; otherwise
    other set implementations would be constrained to implementing a hash
    that's compatible with ours.
    dc61cdf6
Adı
Son kayıt (commit)
Son güncelleme
Demo Loading commit data...
Doc Loading commit data...
Grammar Loading commit data...
Include Loading commit data...
Lib Loading commit data...
Mac Loading commit data...
Misc Loading commit data...
Modules Loading commit data...
Objects Loading commit data...
PC Loading commit data...
PCbuild Loading commit data...
Parser Loading commit data...
Python Loading commit data...
RISCOS Loading commit data...
Tools Loading commit data...
.cvsignore Loading commit data...
.hgtags Loading commit data...
LICENSE Loading commit data...
Makefile.pre.in Loading commit data...
README Loading commit data...
configure Loading commit data...
configure.in Loading commit data...
install-sh Loading commit data...
pyconfig.h.in Loading commit data...
setup.py Loading commit data...