Python Virtual File System: A spike test
Duncan Booth
duncan at NOSPAMrcp.co.uk
Thu Jun 13 04:29:53 EDT 2002
"Mike C. Fletcher" <mcfletch at rogers.com> wrote in
news:mailman.1023900618.26500.python-list at python.org:
> Equality-testing is useful for:
<various good answers snipped>
I think the important thing is that all these scenarios use equality to
optimise something, so it isn't the end of the world if they occasionally
fail to detect equality, although it could be nasty if they returned two
paths as equal when they were actually different.
> it definitely is tricky, but it's one of the major things I want in
> the package (and, after all, if there's no tricky code in the system,
> why is someone going to use it instead of rolling their own). I wind
> up with code to
> do this stuff all over my packages otherwise, I'd like to localise it
> somewhere.
>
Oh good, you want to do some tricky things. :-)
> Will need to add special-casing for "local machine" unc, though
> I don't see how to do it with cases other than \\.\ given that the
> local machine name isn't immediately available as far as I know.
I'm not sure I have even seen any good documentation that completely
specifies UNC filenames on windows. You may have to handle \\? as well as
\\., if you want completeness, but I suspect the law of diminishing returns
kicks in somewhere.
IF you have the win32 extensions around you can always call
win32net.NetWkstaGetInfo to get the machine name, although I must admit
that the last time I wanted to get the machine name I used os.popen('NET
NAME') and parsed the output. Another option would be to read the
appropriate registry keys, which doesn't require the win32 stuff.
--
Duncan Booth duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
More information about the Python-list
mailing list