On Wed, May 13, 2020 at 4:38 AM Ethan Furman <[email protected]> wrote:
>
> > - 
> > https://github.com/python/cpython/blob/27c0d9b54abaa4112d5a317b8aa78b39ad60a808/Lib/os.py#L510
>
> Wow -- I don't even know how to parse that!
>

Wow, that's quite an example. Of something, I'm not sure what, but
definitely an example. Based on two booleans, entries is either None
or a list. If it's None, this loops over just the directory names; if
it's a list, then it's been populated in perfect parallel to dirs (see
the preceding loop), thus guaranteeing that the two lists are
perfectly parallel. But in that case, "name" actually gets a tuple of
(name,entry), and then inside the loop, it does a three-way branch
that is guaranteed (and asserted) to split out the name and entry ONLY
when there actually will be one.

Definitely an odd piece of code. But it can never zip over things of
different lengths.

ChrisA
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/P6K3JGADX5A34CY2VOKVCJDYTDX3WQEY/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to