mirror of https://github.com/python/cpython
Keep doctests in sync with the docs.
This commit is contained in:
parent
7ceb29e4a5
commit
1954035a47
|
@ -634,10 +634,10 @@ Example from the Library Reference: Doc/lib/libsets.tex
|
||||||
... return Base._repr(self, sorted=True)
|
... return Base._repr(self, sorted=True)
|
||||||
>>> engineers = Set(['John', 'Jane', 'Jack', 'Janice'])
|
>>> engineers = Set(['John', 'Jane', 'Jack', 'Janice'])
|
||||||
>>> programmers = Set(['Jack', 'Sam', 'Susan', 'Janice'])
|
>>> programmers = Set(['Jack', 'Sam', 'Susan', 'Janice'])
|
||||||
>>> management = Set(['Jane', 'Jack', 'Susan', 'Zack'])
|
>>> managers = Set(['Jane', 'Jack', 'Susan', 'Zack'])
|
||||||
>>> employees = engineers | programmers | management # union
|
>>> employees = engineers | programmers | managers # union
|
||||||
>>> engineering_management = engineers & programmers # intersection
|
>>> engineering_management = engineers & managers # intersection
|
||||||
>>> fulltime_management = management - engineers - programmers # difference
|
>>> fulltime_management = managers - engineers - programmers # difference
|
||||||
>>> engineers.add('Marvin')
|
>>> engineers.add('Marvin')
|
||||||
>>> print engineers
|
>>> print engineers
|
||||||
Set(['Jack', 'Jane', 'Janice', 'John', 'Marvin'])
|
Set(['Jack', 'Jane', 'Janice', 'John', 'Marvin'])
|
||||||
|
@ -646,7 +646,7 @@ False
|
||||||
>>> employees.update(engineers) # update from another set
|
>>> employees.update(engineers) # update from another set
|
||||||
>>> employees.issuperset(engineers)
|
>>> employees.issuperset(engineers)
|
||||||
True
|
True
|
||||||
>>> for group in [engineers, programmers, management, employees]:
|
>>> for group in [engineers, programmers, managers, employees]:
|
||||||
... group.discard('Susan') # unconditionally remove element
|
... group.discard('Susan') # unconditionally remove element
|
||||||
... print group
|
... print group
|
||||||
...
|
...
|
||||||
|
|
Loading…
Reference in New Issue