How to read a file from another server? Newbie

Peter Hansen peter at engcorp.com
Tue Apr 27 07:22:50 EDT 2004


djw wrote:

> Ivan Voras wrote:
>> Edward Diener wrote:
>>> x = open("servername://path/to/file", "r")
>>
>> Um, what does this to? What protocol does it use?
> 
> I can see how this might work for a Windows server, but wouldn't the 
> forward slashes need to be back slashes? And the path to the file would 
> have to be a shared drive on the server.

"Might work" being the operative words.  Actually "won't work"
is more correct, though. ;-)

Two points:

1. Forward slashes are perfectly fine on Windows,
provided you are not passing the path to the shell/command line/cmd.exe
or whatever.  Internally Windows can cope with forward slashes very
nicely, and they often make it easier or more readable than resorting
to raw strings with r'path\file' all the time.

2. Its unlikely the server name should come first and with a colon
following.  More likely //servername/path/to/file is closer to what
is wanted.

-Peter



More information about the Python-list mailing list