Is it bad practice to use a built-in function name as an attribute or method identifier?

前端 未结 4 755
眼角桃花
眼角桃花 2020-11-30 05:50

I know to never use built-in function names as variable identifiers.

But are there any reasons not to use them as attribute or method identifiers?

For examp

4条回答
  •  一整个雨季
    2020-11-30 06:00

    It won't confuse the interpreter but it may confuse people reading your code. Unnecessary use of builtin names for attributes and methods should be avoided.

    Another ill-effect is that shadowing builtins confuses syntax highlighters in most python-aware editors (vi, emacs, pydev, idle, etc.) Also, some of the lint tools will warn about this practice.

提交回复
热议问题