On 2023-03-10 at 22:16:05 -0500, Thomas Passin <li...@tompassin.net> wrote:
> I'd make the pattern in this example even more understandable and less > error-prone: > > def update_pids(target): > cmd = ["tail", "-n", "1", "-f", f"/var/log/{target}"] > pids.update({target: subprocess.Popen(cmd)}) if not \ > pids[target] else None I might be missing something, but how is that more understandable and less error prone than any of the following: if not pids[target]: cmd = ["tail", "-n", "1", "-f", f"/var/log/{target}"] pids.update({target: subprocess.Popen(cmd)}) or: cmd = ["tail", "-n", "1", "-f", f"/var/log/{target}"] pids[target] or pids.update({target: subprocess.Popen(cmd)}) or: if pids[target]: pass else: cmd = ["tail", "-n", "1", "-f", f"/var/log/{target}"] pids.update({target: subprocess.Popen(cmd)}) Picking a nit, that's not a good place to continue that line with the backslash, either. IMO, "not pids[target]" should be atomic. -- https://mail.python.org/mailman/listinfo/python-list