oreoorlando.blogg.se

Are dictionaries mutable
Are dictionaries mutable









are dictionaries mutable are dictionaries mutable

For example, if you wanted to have a multithreaded program- you want to do some parallel processing there- you wouldn’t have to worry about locking the data structure because there was no way to update it. In the beginning, I said, you know, one of the core tenants of functional programming is actually that you mainly work-or ideally, always work with immutable data structure.Ġ2:11 You want a data structure that can’t be modified that way because if you represent your data using immutable data structures, it has some really interesting properties. The only thing that I don’t really like about this is that, A, we’ve got a mutableĠ1:25 data structure here, so we have a list of these dictionaries-and by mutable,Ġ1:33 I mean that I can just reach in here and I can say, “Okay, we’re going to grab the first scientist here.” I’m just going to reach inside this data structure, and I’m going to rename Ada, give her a different name, right? And now when I print this out, we actually modified the 'name' of the scientist and it kind of screws up the data. They’re represented by dictionaries, which is kind of neat. This looks kind of nice, right?Ġ1:11 We have individual items here. Now, we have this data inside Python and we can work with that. I would do something like that, right? And then just have a list of those.Ġ0:49 And you can imagine that there would be some more here, so let me just copy and paste that. 00:00 When I started thinking about this tutorial, my first hunch was, “Okay, if I want to bring this into Python, I’d probably have a list of dictionaries.” So I could say, okay, scientists = and then I would just have a list of dictionary objects- I should probably indent that-and I would put different keys, like 'name',Ġ0:25 and I would put the respective field for the person,Ġ0:31 and I would put the year they were born,Ġ0:37 and then I would have some kind of flag that tells me whether or not they won the Nobel Prize.











Are dictionaries mutable