3 ms·
The values in tuples cannot change. The values that keys point to in a frozen dict can? But yeah I'd be in favour of something that looked a lot like a named
by willvarfar 10mo ago
The values in tuples cannot change. The values that keys point to in a frozen dict can?
But yeah I'd be in favour of something that looked a lot like a named tuple but with mutable values and supporting [name] access too. And of course some nice syntactic sugar rather like dicts and sets have with curly brackets today.
- pansa2 10mo ago> The values in tuples cannot change. The values that keys point to in a frozen dict can? The entries of a tuple cannot be assigned to, but the values can be mutated. The same is true for a `frozendict` (according to the PEP they don't support `__setitem__`, but "values can be mutable").
- vscode-rest 10mo agoTuple entries must be hashable, which (as far as standard library is concerned) means immutable.
- pansa2 10mo ago>>> hash([1, 2]) TypeError: unhashable type: 'list' >>> t = ([1, 2], [3, 4]) >>> print(t) ([1, 2], [3, 4])
- vscode-rest 10mo agoAh. Of course… that’s how the workaround to use tuples as frozen dicts can work in the first place. Slow morning for me!