[Python-Dev] Convention on functions that shadow existing stdlib functions

R. David Murray rdmurray at bitdance.com
Wed Jul 27 17:11:10 CEST 2011


On 2011年7月27日 16:58:53 +0300, Eli Bendersky <eliben at gmail.com> wrote:
> R. David Murray wrote:
> > But they aren't redundant, since the test.support versions ignore
> > errors.
>> As I mentioned elsewhere, it's not good practice to have two functions with
> the same name doing something slightly different, in different modules in
> the code-base.

Well, that would seem to be a matter of opinion. I see your point, but
I'm not sure that I agree. But see below.
> What do you mean by vetting the test suite so that unlink is always taken
> from test.support? I suppose some tests would specifically want the original
> unlink's functionality. In fact, at least a few tests use os.unlink
> exlicitly.

What I mean is that if the test code always did:
 import support
 [...]
 support.unlink('testtempfile')
then there would be no confusion when someone grepped the code for
'unlink' or was reading the code without having noticed the import.
That is, give the functions a unique name by using the 'support'
name space explicitly, rather than by renaming them within the
module.
--
R. David Murray http://www.bitdance.com


More information about the Python-Dev mailing list

AltStyle によって変換されたページ (->オリジナル) /