I have the following setup:
co_occurrences = defaultdict(lambda: defaultdict(int))
# Populate the dictionary...
for word, occurrence_vector in co_occurrences:
if word == "__length": continue
for file_name, occurrence_count in occurrence_vector:
co_occurrences[word][file_name] = occurrence_count / co_occurrences["__length"][file_name]
Is this line:
co_occurrences[word][file_name] = occurrence_count / co_occurrences["__length"][file_name]
dangerous? By dangerous, I mean that I want to iterate over each key once and only once, so any code that modfies this behavior is dangerous. I feel like it might be since I am modifying the data structure I am iterating over.