How to know a top directory?

Grigory Temchenko soid.exe at gmail.com
Sat Aug 23 18:20:39 EDT 2008


On Aug 23, 5:24 am, Fredrik Lundh <fred... at pythonware.com> wrote:
> Michiel Overtoom wrote:
> >> I have path "/this/is/path" and I wanna get "/this/is".
> >> Also I want to use it as platform independent. If I want to pass "c:
> >> \that\path" then I need to get "c:\that".
>
> > import os
> > print os.path.split("/home/user/motoom")[0]
> > print os.path.split("c:\\prj\\techniques\\python")[0]
>
> in this case, os.path.dirname() is more convenient.
>
> </F>

Thanks a lot!



More information about the Python-list mailing list