Not having an issue completing the project but just curious about how something works. I’ve tried thinking it through but my brain is just exploding. Link to the project is here.
def sell_artwork(self, artwork, price): if artwork.owner == self: new_listing = Listing(artwork, price, self) veneer.add_listing(new_listing)
What this function is meant to do is make a new instance of Listings with the given parameters, then put it into the Marketplace immediately. All fine. It works. My question is how come when I run it more than once, the previous ‘new_listing’ doesn’t get overriden? I ran it and sure, it works just fine (which I thought it would break!). But why? Surely it would have made new_listing the new one, since there is only one object called new_listing in Listings, even after it’s added to the Marketplace.
Hope I’m explaining my question clearly:
- How come when I run this code, I create a new Listing without over-writing the previous one, given I have no way of assigning it a different name?