multithreading

Kiuhnm kiuhnm03.4t.yahoo.it
Sat Apr 7 17:06:01 EDT 2012


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



More information about the Python-list mailing list