On 9/21/19 10:02 AM, Mats Wichmann wrote:
> On 9/20/19 4:36 PM, Stephen Satchell wrote:
>> On 9/20/19 2:47 PM, Tim Stumbaugh wrote:
>>> You get the same pylint warning, but better yet, you get a `NameError`
>>> raised at the point of the `del`. Your suggestion of moving the loop to the
>>> function would alleviate the problem, since there would be no need for the
>>> explicit `del`. If that's unavoidable, you could add an explicit `device =
>> Indeed.  I duplicated your code and found that it works exactly how you
>> described.  The situation where the original list would be empty isn't
>> supposed to happen...famous last words.
> that's what try/except is for :)

True that.  In this particular situation, though, the more elegant
solution was to indeed break up the processing into separate functions,
with their own name spaces, and explicit passing of data structures.

It improved the structure, and thus maintainability of the code. Also
reduces name pollution.
_______________________________________________
code-quality mailing list -- code-quality@python.org
To unsubscribe send an email to code-quality-le...@python.org
https://mail.python.org/mailman3/lists/code-quality.python.org/

Reply via email to