Re: How to know a top directory?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fredrik Lundh

    Re: How to know a top directory?

    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\\techni ques\\python")[0]
    in this case, os.path.dirname () is more convenient.

    </F>

  • Grigory Temchenko

    #2
    Re: How to know a top directory?

    On Aug 23, 5:24 am, Fredrik Lundh <fred...@python ware.comwrote:
    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\\techni ques\\python")[0]
    >
    in this case, os.path.dirname () is more convenient.
    >
    </F>
    Thanks a lot!

    Comment

    Working...