On Fri, Sep 24, 2021 at 11:43 PM Peter Saalbrink
wrote:
>
> I don't think this has anything to do with typing or providing type hints.
> The type hint is the `: set` part, not the `= set()` part.
> You can declare the type without assigning to the variable.
> Indeed, as you already said, `x` is a
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 Fo
I don't think this has anything to do with typing or providing type hints.
The type hint is the `: set` part, not the `= set()` part.
You can declare the type without assigning to the variable.
Indeed, as you already said, `x` is a class property here, and is shared
amongst instances of the class.
Hi all,
this just caused me several hours of my life until I could whittle it down to
this minimal example. Simple question: Why is the x member of object "foo"
modified by initializing "bar"?
Obviously, initializing foo with None doesn't set foo.x at all. So I guess x
stays a class property, not