473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

</F>

Aug 23 '08 #1
1 862
On Aug 23, 5:24*am, Fredrik Lundh <fred...@pythonware.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\\techniques\\python")[0]

in this case, os.path.dirname() is more convenient.

</F>
Thanks a lot!
Aug 23 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: nan | last post by:
Hi all. Anyone has an idea of how to open a file without know the complete name of it, without opening the directory (with opendir) and test each file? For example, I have this: ...
1
by: Frank Lopez | last post by:
In .NET and C#, is there anyway to create a hook for a specific directory or file where my C# .NET software can monitor which static web files are requested by the browser? What I am doing is...
5
by: Michael C | last post by:
....on a remote machine? Thanks, Michael C.
6
by: dave | last post by:
I really have 2 questions regarding the following xml snippet. The xml is a directory representation. <?xml version="1.0" standalone="yes"?> <FileSystem> <Row> <ID>1</ID> <Name>Root</Name>...
5
by: spookyu | last post by:
Alright, I'm sure your tired to hearing this but...does anyone know of any GOOD tutorial's for learning c#. The more basic the better, I have NO experience with programing before this other than...
12
by: Antonio Maschio | last post by:
Hi, I need help. I want to read text files contained into a directory, but my program is unaware of how many files are contained into. In bash there's something similar to (figure out) for i...
4
by: bill | last post by:
I have a directory into which I upload pictures. I know the entire file name other than the extension. file_exists will return true when I give it a wildcard extension, but I can't figure out...
2
by: moishyyehuda | last post by:
Hi Does any one know of any good folder/directory modules. I need to be able to see what files and directories are in a folder, I also need to be able to see the size of the directory content. ...
63
by: David Mathog | last post by:
There have been a series of questions about directory operations, all of which have been answered with "there is no portable way to do this". This raises the perfectly reasonable question, why,...
7
by: devnew | last post by:
hi i am trying to create a cache of digitized values of around 100 image files in a folder..In my program i would like to know from time to time if a new image has been added or removed from the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.