[Tutor] Can't figure out why this is printing twice

Lie Ryan lie.1296 at gmail.com
Tue Jun 9 15:31:37 CEST 2009


Mike Hoy wrote:
>     On Tue, Jun 9, 2009 at 6:34 AM, The Green Tea Leaf
>     <thegreentealeaf at gmail.com <mailto:thegreentealeaf at gmail.com>> wrote:
> 
>         I got an email from him that he had a gzip.pyc file in that folder.
>         Once he deleted that everything works OK.
> 
> 
>     Heh... I think I've made that mistake before;
> 
>     "My import statement doesn't work right! When I "import <somelib>"
>     it tells me none of the methods are available!"
> 
>     And then I realize my file was named that. Doh!
> 
>     live and learn though, eh?
> 
> Yea and I knew better than to do that too. Guess I had to make the
> mistake to really get it into my head.. Funny how that works. You read
> all about that stuff in books, but you don't actually know it until you
> put it into practice.

I think most people have done this at least once in their life; I still
remember when I did it... not only once, in fact...

And I think it is one of the most frequent cause of "misbehaving
libraries"...

Maybe python should issue some kind of warning when a module being
imported from a local path has the same name as an installed module? It
is never a good idea to name a module the same as an installed library
unless you're deliberately trying to shadow the library for some reason
(in which case you're a fully consenting adult).



More information about the Tutor mailing list