Aug-11-2018, 02:05 AM
(Aug-10-2018, 05:44 PM)PySimpleGUI Wrote: Check out this bit of Python magic!
class ListDict(OrderedDict): def __iter__(self): for v in self.values(): yield v def __getitem__(self, item): if isinstance(item, slice): return list(self.values())[item] else: return super().__getitem__(item)This way there is no need to call value.values. I can access the return values in both dictionary style and as a list! I think it's kinda brilliant. I can't take credit for it however :-) But I can freely use it!
Why bring complexity into this situation when you have a simple soultion? The ListDict may be a cute design but is verbose here and creates extra obstacle to the user.