Assuming your class constructor's interface is set and you can't change it (or don't want to), so the randomization part needs to be inside __init__. And also assuming that just "assuring" there are no dupes in a list of Targets is primarily what you want, without any further assumptions made on what you're exactly trying to achieve.
Then, as a first step, you would require for the Targets to be comparable to each other, based on their x and y values.This can be implemented in the __eq__ method:
def __eq__(self, other):
return self.x == other.x and self.y == other.y
Alongside, you need to create __hash__, which is required to be equal for objects that are equal based on __eq__, and also because reimplementing __eq__ resets the default __hash__ so Target wouldn't be hashable without:
def __hash__(self):
return hash((self.x, self.y)) # just use the tuple's hash
Now you can compare Targets with one another based on their (x,y) data:
Target() == Target()
This worked before, too, but would return if the two targets are the same object, which may be False even with the same x and y.
With this as the basis, you can now assert there are no dupes in your list of targets
targets = [Target() for in range(10)]
by turning it into a set, which removes dupes based on equality based on __eq__, and then comparing the length of the result:
assert len(targets) == len(set(targets))
This is may not be what makes the most sense to do, but a direct answer to your question nonetheless.
a.x == b.x and a.y == b.y, right?