On 6/10/2013 10:56 PM, Steven D'Aprano wrote:

I was initially confused
and reading the code still takes a small bit of extra mental energy.
Idle stays confused and will wrongly color the list instance name until
it is changed. Calling the file list 'fnames' or 'filenames' would have
been clearer to both me and Idle.

Correct. The downside of editors that colourise text is that sometimes
they colourise it wrong. In this case, how is the editor supposed to know
that list no longer refers to the built-in list?

This is yet another good argument for being cautious about shadowing
built-ins.

After posting I remembered that there are also colorized text blocks on web pages. Each person will have to decide for themselves whether the convenience of reusing a builtin name is worth having their code mis-colorized. As a reader, I decided that it is not.

tjr



--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to