Aug-01-2018, 02:07 PM
Code:
How can I compare two or more lists like these (in the dict if possible--so as to not have to worry about writing them to variables) for the newest (or youngest) date?
-m
reg_key = 'SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkList\\Profiles' if ctypes.windll.shell32.IsUserAnAdmin(): with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, reg_key, 0, winreg.KEY_ALL_ACCESS) as k: ns = winreg.QueryInfoKey(k)[0] if ns > 1: subs = [] ts_dict = {} for i in range(ns): subs.append(winreg.EnumKey(k, i)) reg_key2 = reg_key + '\\' + subs[i] with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, reg_key2, 0, winreg.KEY_ALL_ACCESS) as k2: val = winreg.QueryValueEx(k2, 'DateCreated') ts_dict[i] = get_time_stamp(val)The dict
ts_dict
returns numeric keys with a list as the value for each key. What is the best way to compare these two lists (values)? The lists are timestamps ordered like so [<year>, <month>, <day of week>, <day>, <hour>, <minute>, <second>]. They are all numeric, so a real example would be [2018, 8, 3, 1, 10, 2, 16]
which is today's date at 10:02:16AM.How can I compare two or more lists like these (in the dict if possible--so as to not have to worry about writing them to variables) for the newest (or youngest) date?
-m