def replace_object(rdf, fromuri, touri, predicate=None):
if fromuri == touri:<EOL><INDENT>return<EOL><DEDENT>for s, p in rdf.subject_predicates(fromuri):<EOL><INDENT>if predicate is not None and p != predicate:<EOL><INDENT>continue<EOL><DEDENT>rdf.remove((s, p, fromuri))<EOL>if touri is not None:<EOL><INDENT>if not isinstance(touri, (list, tuple)):<EOL><INDENT>touri = [touri]<EOL><DEDENT>for uri in touri:<EOL><INDENT>rdf.add((s, p, uri))<EOL><DEDENT><DEDENT><DEDENT>
Replace all occurrences of fromuri as object with touri in the given
    model.

    If touri=None, will delete all occurrences of fromuri instead.
    If touri is a list or tuple of URIRef, all values will be inserted.
    If predicate is given, modify only triples with the given predicate.