One function

Events in pyeve/events

The author described this change as Fix Events.__len__ counting __events__. It counts as a record because the check below fails on the code as it stood at 8e94730d4 and passes on e1895e27a, with nothing else changed between the two runs.

Fix saved2020-10-31
Sharing licenceBSD-2-Clause · LICENSE
Change size+1 1

What the code was meant to do, written into the code itself as a docstring

Encapsulates the core to event subscription and event firing, and feels like a "natural" part of the language. The class Events is there mainly for 3 reasons: - Events (Slots) are added automatically, so there is no need to declare/create them separately. This is great for prototyping. (Note that `__events__` is optional and should primarilly help detect misspelled event names.) - To provide (and encapsulate) some level of introspection. - To "steel the name" and hereby remove unneeded redundancy in a call like: xxx.OnChange = event('OnChange')

The change

5252 __str__ = __repr__
5353
5454 def __len__(self):
55- return len(self.__dict__.items())
55+ return len(list(self.__iter__()))
5656
5757 def __iter__(self):
5858 def gen(dictitems=self.__dict__.items()):

The check that tells the two apart

failpass·events/tests/tests.py::TestEvents::test_len

Check file events/tests/tests.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it8e94730d404c5a40feb219fd94eca6ed44c1d757
Broken version dated2020-10-31
Moduleevents.events
Units changedEvents
Fingerprintef8d3a26660a4a70
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.