[Tutor] masking library files

Alan Gauld alan.gauld at btinternet.com
Wed Apr 9 17:56:29 CEST 2014

On 09/04/14 15:17, ugajin at talktalk.net wrote:
> Is it common for files saved to a working directory to 'mask' library
> files located in the Python framework?

Python looks in the local directory first so if you name a module with 
the name of one of the standard modules Python will, quite reasonably, 
assume you want your module to be used rather than the standard one.

The best solution is not to name your modules the same as the
standard library ones.

When it comes to non-standard libraries then it becomes a matter of 
looking at the sys.path value and the order of search defined there.
Which may, in turn, depend on how they were installed.

Alan G
Author of the Learn to Program web site

More information about the Tutor mailing list