Swapping Content of Two Dictionaries.

Stefan Behnel stefan_ml at behnel.de
Wed Mar 17 15:10:27 CET 2010

Hatem Oraby, 17.03.2010 12:26:
> However, consider the case in which the dictionary we are referencing lives
> in another module:
> #external.py
> #
> #a = {1:"I'am A}
> import external
> temp = external.a
> external.a = b
> b = temp

Looks like the interface of your module is broken. It shouldn't export the 
two dicts.

> My problem is that i need to do this operation a LOT, simply I got a problem
> that my program go through a very long loop and inside this loop this
> operation is needed to be done twice and the dictionary size ain't very
> small.

Please explain what you use the dicts for and how they are supposed to be 
used by your own code and by external code. That will allow us to give an 
advice on how to design your module better.


More information about the Python-list mailing list