Skip to content

Compare values and update only when different from previous #596

@lubianat

Description

@lubianat

Hi!
I have some code that pull some items from my wikibase, adds (or not) information, and then tries to write to the Wikibase:
This is the final snippet:

            item.claims.add(data, action_if_exists=ActionIfExists.REPLACE_ALL)

            old_item_dict = old_item.__dict__
            new_item_dict = item.__dict__

            if old_item_dict == new_item_dict:
                print("No change")
            else:
                try:
                    item.write()
                except ModificationFailed as e:
                    print(e)
                    pass

This comparison, however, is not working. I want to implement that ifelse statement to avoid talking to the server whenever I don't have anything new to write. Any thoughts?

Thanks!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions