On Wed, Apr 25, 2018 at 8:22 PM Chris Angelico <ros...@gmail.com> wrote: [..] > > my_func(arg, buffer=(buf := [None]*get_size()), size=len(buf)) > > > > To my eye this is an anti-pattern. One line of code was saved, but the > > other line becomes less readable. The fact that 'buf' can be used after > > that line means that it will be harder for a reader to trace the origin of > > the variable, as a top-level "buf = " statement would be more visible.
> Making 'buf' more visible is ONLY a virtue if it's going to be used > elsewhere. Otherwise, the name 'buf' is an implementation detail of > the fact that this function wants both a buffer and a size. Should you > want to expand this out over more lines, you could do this: Chris, you didn't read that paragraph in my email to the end or I did a poor job at writing it. My point is that "buf" can still be used below that line, and therefore sometimes it will be used, as a result of quick refactoring or poor coding style. It's just how things happen when you write code: it gets rewritten and parts of it left outdated or not properly revised. *If* "buf" is used below that line it *will* be harder to find where it was initially set. Anyways, I don't want to distract everyone further so I'm not interested in continuing the discussion about what is readable and what is not. My own opinion on this topic is unlikely to change. I wanted to explain my -1; hopefully it will be noted. Yury _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com