summaryrefslogtreecommitdiffstats
path: root/Lib/rfc822.py
diff options
context:
space:
mode:
authorThomas Wouters <thomas@python.org>2000-08-24 20:14:10 (GMT)
committerThomas Wouters <thomas@python.org>2000-08-24 20:14:10 (GMT)
commit104a7bcc28f96c6192815e82971d660c9910c16b (patch)
tree9154c2e6b47cc4721c648457e7762e804ca97e2e /Lib/rfc822.py
parent434d0828d81855692d45c3fdc0905a67c17d83ba (diff)
downloadcpython-104a7bcc28f96c6192815e82971d660c9910c16b.zip
cpython-104a7bcc28f96c6192815e82971d660c9910c16b.tar.gz
cpython-104a7bcc28f96c6192815e82971d660c9910c16b.tar.bz2
Support for augmented assignment in the UserList, UserDict, UserString and
rfc822 (Addresslist) modules. Also a preliminary testcase for augmented assignment, which should actually be merged with the test_class testcase I added last week.
Diffstat (limited to 'Lib/rfc822.py')
-rw-r--r--Lib/rfc822.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/rfc822.py b/Lib/rfc822.py
index 6473149..42aac1c 100644
--- a/Lib/rfc822.py
+++ b/Lib/rfc822.py
@@ -763,6 +763,13 @@ class AddressList(AddrlistClass):
newaddr.addresslist.append(x)
return newaddr
+ def __iadd__(self, other):
+ # Set union, in-place
+ for x in other.addresslist:
+ if not x in self.addresslist:
+ self.addresslist.append(x)
+ return self
+
def __sub__(self, other):
# Set difference
newaddr = AddressList(None)
@@ -771,6 +778,13 @@ class AddressList(AddrlistClass):
newaddr.addresslist.append(x)
return newaddr
+ def __isub__(self, other):
+ # Set difference, in-place
+ for x in other.addresslist:
+ if x in self.addresslist:
+ self.addresslist.remove(x)
+ return self
+
def __getitem__(self, index):
# Make indexing, slices, and 'in' work
return self.addresslist[index]