Get dict value but not as reference.

Robert Rawlins robert.rawlins at thinkbluemedia.co.uk
Wed Jul 23 17:49:11 CEST 2008


Guys,

 

This feels like a strange question but it's not something I've done before,
I'm sure it's quite simple.

 

I have a dictionary, and I want to get one of the values from it, but rather
than returning it as a reference I want to actually detach/remove the
element from the dictionary. Like so:

 

Def get_something():

                Something = self.my_dict["keythatIwanttoredetach"]

 

                Return something

 

I can then use something, however, it no longer exists in the dictionary.

 

Sorry, I couldn't really explain this very well. How can I achieve this?

 

Cheers,

 

Robert

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080723/f67a85f8/attachment.html>


More information about the Python-list mailing list