SocketServer inconsistencies

Daniel Klein DanielK at jBASE.com
Tue Feb 13 19:18:45 EST 2001


Big slap on forehead!!!! :^(

This is one lesson I will NEVER forget.

Thanks to you and /F I am now a happy parrot instead of a dead one. :^)

Dan

"I shot an error into the air. It's still going everywhere."


"Penfold" <spam at spam.com> wrote in message
news:t8jisec2vrr24 at corp.supernews.com...
> 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 "socketserver.py", or at
least
> one of *your* modules is named that ...
> note your error
>
> > NameError: Case mismatch for module name SocketServer
> > (filename C:\DanielK\python\socketserver.py)
>                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> 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 SocketServer.py [would you
> call one of your own modules sys.py or os.py or string.py ?? i hope not
;-)]
>
> Have a nice day
>
> D
> "Daniel Klein" <DanielK at jBASE.com> wrote in message
> news:ycji6.241$Vf.9600 at typhoon.aracnet.com...
> > 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
> returns
> >
> > >>> import SocketServer
> > Traceback (innermost last):
> >   File "<pyshell#0>", line 1, in ?
> >     import SocketServer
> > NameError: Case mismatch for module name SocketServer
> > (filename C:\DanielK\python\socketserver.py)
> >
> > ...however when I try 'import socketserver' (note the case of the
> command),
> > 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
> please?
> > 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
> to
> > 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