On 4/7/2012 22:09, Bryan wrote:
For instance, let's say I want to make this code thread-safe:

--->
myDict = {}

def f(name, val):
      if name not in myDict:
          myDict[name] = val
      return myDict[name]
<---

First, don't re-code Python's built-ins. The example is a job for
dict.setdefault().
[...]

That was just an example for the sake of the discussion.
My question is this: can I use 'threading' without interfering with the program which will import my module?

Kiuhnm
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to