Skip to content

Object Watchdog uses existing instance instead of creating new instances #1

@ghost

Description

Imagine having the following snippet:

class A(metaclass=ObjectWatchdog):
	def __init__(self, number: int):
		self.number = number

a = A(1)
b = A(2)

What do we expect? We expect a.number == 1 and b.number == 2. However, when printing the a.number we see 2 (!). Adding a print statement before setting the number at initialization level (print(hasattr(self, "number"))) reveals that self.number is already set on instance b.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions