On 24/09/21 5:48 pm, Robert Latest wrote:
Never use mutable types in type hint,
No, the lesson is: Don't mutate a shared object if you don't want
the changes to be shared.
If you want each instance to have its own set object, you need to
create one for it in the __init__ method, e.g.
class Foo():
x : set
def __init__(self, s):
self.x = set()
if s:
self.x.add(s)
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
