Created
January 5, 2024 04:08
-
-
Save audiodude/01d6f14777d80d28cbb5aa2af7726de0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Fruit: | |
def __init__(self, name): | |
self.name = name | |
apple = Fruit('apple') | |
apples = { | |
'apple': apple, | |
'red apple': apple, | |
'a': apple, | |
} | |
apples['a'].name = 'banana' | |
print(list(a.name for a in apples.values())) | |
# | |
# => ['banana', 'banana', 'banana'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment