Python copying or cloning a defaultdict variable

How can I make a duplicate copy (not just assigning a new pointer to the same location in memory) of Python's defaultdict object?

from collections import defaultdict
itemsChosen = defaultdict(list)    
dupChosen = itemsChosen
print dupChosen

What the code above does is a shallow copy and returns

defaultdict(<type 'list'>, {1: [1], 2: [1]})

whereas what I'm looking for it to return

defaultdict(<type 'list'>, {1: [1]})



Use copy:

from copy import copy

dupChosen = copy(itemsChosen)

In case of multiple nestings there is also deepcopy.

Need Your Help

Replace with full twitter link using API

php regex twitter

I am currently using the EpiTwitter API to grab Tweets and store them in the database however I want to replace any '' links in a given tweet and replace them with the full links. The regex is ...

rails, rack-cors, nginx, angualrjs and cors

ruby-on-rails nginx cors rails-api rack-cors

Still getting "Origin is not allowed by Access-Control-Allow-Origin." errors.