Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -1118,12 +1118,14 @@ def _timer_set_single_shot(self):
def _on_timer(self):
'''
Runs all function that have been registered as callbacks. Functions
can return False if they should not be called any more. If there
can return False (or 0) if they should not be called any more. If there
are no callbacks, the timer is automatically stopped.
'''
for func, args, kwargs in self.callbacks:
ret = func(*args, **kwargs)
if not ret:
# docstring above explains why we use `if ret == False` here,
# instead of `if not ret`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment doesn't really help, nor does the docstring. This code is not very pythonic (I would guess this was written by someone who comes from , and I think a good explanation is necessary in case of more code "cleanup".

Also, this code will break if the function called returns the integer 0 (if that is ever the case..)

My 2 cents,
N

if ret == False:
self.callbacks.remove((func, args, kwargs))

if len(self.callbacks) == 0:
Expand Down