0

We can do the following for lists:

>>> a = [1, 2, 3, 4, 5, 6]
>>> b = []
>>> id(a)
140093169968840
>>> id(b)
140093169868528
>>> b[:] = a
>>> b
[1, 2, 3, 4, 5, 6]
>>> id(b)
140093169868528

b retains memory reference

Is there a way to do the same for two dictionaries in Python 2.7?

>>> a = {'one' :1, 'two' :2}
>>> b = {}
>>> b[...] = a  # ?

UPDATE: The answer is "No, there's no syntax sugar for dictionaries." It's not a duplicate. I'm not looking for a way to do it, othere that using syntax sugar.

olekb
  • 638
  • 1
  • 9
  • 28

0 Answers0