Is it safe to modify a mutable object returned by a method of a standard library object?
Here's one specific example; but I'm looking for a general answer if possible.
#m is a MatchObject
#I know there's only one named group in the regex
#I want to retrieve the name and the value
g, v = m.groupdict().popitem()
#do something else with m
Is this code safe? I'm concerned that by changing groupdict() I'm corrupting the object m (which I still need for later).
I tested this out, and a subsequent call to m.groupdict() still returned the original dictionary; but for all I know this may be implementation-dependent.