[Pythonmac-SIG] Fixing the documentation...

Ronald Oussoren ronaldoussoren at mac.com
Thu Apr 20 20:38:43 CEST 2006


On 20-apr-2006, at 19:49, Russell Finn wrote:
>
>> More examples of brokenness:
>>
>> exists('d1:Users:has')
>> False
>> exists('/Users/has')
>> True
>
> [snip]
>
> If d1 is the name of your system volume, then that would be a bug --
> if you were explicitly calling macpath.exists() in the first case.  If
> you're calling os.path.exists() under Mac OS X, then you're really
> getting posixpath.exists():

Right. Any function that touches the actual filesystem won't work,  
just like you can't expect that ``ntpath.exists(r'\Users\has')``  
returns True. The modules posixpath, ntpath and macpath are available  
on all platform just to be able to just somepath.join and other  
string manipulation functions on other types of platform.

Contrary to what I thought this isn't mentioned as a goal/possibility  
in the library reference, appearently this was part of folkore when I  
learned python.

>
>>>> os.path.exists
> <function exists at 0x38d70>
>>>> macpath.exists
> <function exists at 0x58a70>
>>>> posixpath.exists
> <function exists at 0x38d70>
>
>> So the module is well broken on OS X, and has been for the last  
>> five years and nobody's said or done anything about it yet.
>
> Only if you believe it should handle HFS and POSIX paths
> interchangeably.  I don't believe it's "broken", but I won't claim it
> does much that's useful in the modern world other than handle
> HFS-style paths (if you happen to have one for some reason).

Which happens with some Carbon related APIs and appeantly also some  
scripting interfaces.

>
> Some interoperability functions (i.e. conversion between HFS and POSIX
> paths) might be useful for the benefit of older (pre-X) scripts that
> assumed HFS conventions, but the fact that no one's been clamoring for
> them suggests that the need isn't very urgent today.

Those functions exists and are part of the normal Carbon API's.  
macpath is an implementation for the path manipulation APIs in  
os.path for when you want to manipulate OS9 style paths. That is  
*all* it can be used for unless you're running on OS9.

Ronald

>
> -- Russell Finn
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIG at python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig



More information about the Pythonmac-SIG mailing list