From 66e152f718f227ebb830fd325685103c50234d99 Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Wed, 21 Mar 2012 21:18:43 +0000 Subject: [PATCH] Clarify HACKING's shadow built-in guidance. Change-Id: Icf38d3ec3254e83d2289b7b17966ec44d9757b8c --- HACKING.rst | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/HACKING.rst b/HACKING.rst index b7e2564d69a..4d9a1b3f2ce 100644 --- a/HACKING.rst +++ b/HACKING.rst @@ -12,7 +12,18 @@ General - Put one newline between methods in classes and anywhere else - Do not write "except:", use "except Exception:" at the very least - Include your name with TODOs as in "#TODO(termie)" -- Do not name anything the same name as a built-in or reserved word +- Do not shadow a built-in or reserved word. Example:: + + def list(): + return [1, 2, 3] + + mylist = list() # BAD, shadows `list` built-in + + class Foo(object): + def list(self): + return [1, 2, 3] + + mylist = Foo().list() # OKAY, does not shadow built-in Imports