Skip to content

Instantly share code, notes, and snippets.

@njdart
Last active May 26, 2016 09:15
Show Gist options
  • Save njdart/80959df1be8556480322bee708b4520e to your computer and use it in GitHub Desktop.
Save njdart/80959df1be8556480322bee708b4520e to your computer and use it in GitHub Desktop.
import uuid
class Foo():
def __init__(self, id=uuid.uuid4()):
self.id = id
class Bar():
def __init__(self, id=uuid.uuid4()):
self.id = id
class Works():
def __init__(self, id=None):
self.id = id if id is not None else uuid.uuid4()
if __name__ == "__main__":
foo_one = Foo()
foo_two = Foo()
bar_one = Bar()
bar_two = Bar()
works_one = Works()
works_two = Works()
# Makes a new Id for the first, but not the second
print("Foo 1", foo_one.id)
print("Foo 2", foo_two.id)
# Makes a new Id for the first, thats different from Foo's id, but not the second
print("Bar 1", bar_one.id)
print("Bar 2", bar_two.id)
# both works_one and works_two are different ids
print("Works 1", works_one.id)
print("Works 2", works_two.id)
@torincb
Copy link

torincb commented May 26, 2016

Wow, that's pretty messed up. Have you reported this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment