SocketServer inconsistencies

Penfold spam at
Tue Feb 13 19:00:26 EST 2001

There is no *inconsistency* between the platforms.  It seems to me that
you've taken the somewhat dubious step
of naming the test script that you are using "", or at least
one of *your* modules is named that ...
note your error

> NameError: Case mismatch for module name SocketServer
> (filename C:\DanielK\python\

When you import modules, python searches for them on its path (sys.path,
$PYTHONPATH etc).  It looks in the directory of the script it is running
before looking in the library.  Now on linux this is fine ... it looks in
the scripts directory for SocketServer and never finds it (as it is called
socketserver which is a different name on *nix).  On windows however it
strikes a problem.  To Windows, there is no case sensitivity in filenames,
so to all intents and purposes it cant tell the difference between
SocketServer --- so it imports *your* module (not the library one).  But
then its smart enought to figure out that its not quite making sense ... Now
if you import socketserver it of course just runs any code in *your*
socketserver program so its your own fault if thats gone and done something
! [learn about the __name__ == '__main__': pydiom]

So ... solution, call your modules something better than socketserver ... on
windows choosing a module name the same as library module when case is
ignored is just asking for problems.  On linux of course you would have had
a similar problem if you had called your module [would you
call one of your own modules or or ?? i hope not ;-)]

Have a nice day

"Daniel Klein" <DanielK at> wrote in message
news:ycji6.241$Vf.9600 at
> I am attempting to write some socket code which must be platform indepent
> and the following behavior indicates that I can't use the SocketServer
> module as I had hoped to do.
> On Linux using Python 1.5.2, 'import SocketServer' correctly imports into
> the global namespace. On Windows, using Python 2.0, the same command
> >>> import SocketServer
> Traceback (innermost last):
>   File "<pyshell#0>", line 1, in ?
>     import SocketServer
> NameError: Case mismatch for module name SocketServer
> (filename C:\DanielK\python\
> ...however when I try 'import socketserver' (note the case of the
> it actually _starts_  the server, ie
> >>> import socketserver
> Waiting for a connection...
> I know I'm using different version on the different platforms but could
> someone please advise how to use the SocketServer module on Windows
> Has the implementation changed from 1.5.2 to 2.0?
> Please forgive my naivety if the answer is obvious but this is a serious
> problem for me. If I can't use the SocketServer module on Windows, I have
> go back to the drawing board and see what I would need to do to use the
> lower level 'socket' module (which will require a great deal more work,
> especially since I am new to network programming). :^(
> Thanks for listening, and hopefully for an answer,
> Daniel Klein

More information about the Python-list mailing list