Directory Listing output to a file

2006-11-03 Thread wifighost
Hi All,       I am a newbie to the Python language and already love it. I am working on my first script. I am trying to create a script that will get the contents of a directory and export (output) that information in a file that exists or creates. Mainly it’s going to read my net

Re: directory listing

2005-11-12 Thread Shi Mu
thanks a lot! On 11/11/05, Michael Konrad <[EMAIL PROTECTED]> wrote: > > This is what I decided on for a solution. I haven't tested it > cross-platform yet. > > import os > > def dirListing(directory='/Users/mkonrad'): >"""Returns a list of directories.""" >#variabl

Re: directory listing

2005-11-12 Thread [EMAIL PROTECTED]
Shi Mu: Before all you were doing was defining a function with: import os def buildList( directory='c:\TEMP' ): dirs = [ ] listing = os.listdir(directory) for x in listing: x = os.path.join(directory, x) print x if os.path.isdir(x): dirs.append(x)

Re: directory listing

2005-11-11 Thread Michael Konrad
Sorry about that, I guess send was working. Michael Konrad wrote: > > This is what I decided on for a solution. I haven't tested it > cross-platform yet. > > import os > > def dirListing(directory='/Users/mkonrad'): > """Returns a list of directories.""" > #variables > d

Re: directory listing

2005-11-11 Thread Michael Konrad
This is what I decided on for a solution. I haven't tested it cross-platform yet. import os def dirListing(directory='/Users/mkonrad'): """Returns a list of directories.""" #variables dirs = [] #list of directories

Re: directory listing

2005-11-11 Thread Michael Konrad
This is what I decided on for a solution. I haven't tested it cross-platform yet. import os def dirListing(directory='/Users/mkonrad'): """Returns a list of directories.""" #variables dirs = [] #list of directories

Re: directory listing

2005-11-11 Thread Peter Hansen
Shi Mu wrote: > On 11/11/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote: >>Shi Mu wrote: >>>def buildList( directory='c:\TEMP' ): >>>dirs = [ ] >>>listing = os.listdir(directory) >>>for x in listing: >>>x = os.path.join(directory, x) >>>print x >>>if os.path.isdir(x

Re: directory listing

2005-11-11 Thread Fredrik Lundh
"Shi Mu" wrote: > print buildList() gets lots of stuffs from my temp directory(there do > exist lots of files). > But why "print x' has nothing? C:\>more script.py import os def buildList( directory='c:\TEMP' ): dirs = [ ] listing = os.listdir(directory) for x in listing: x =

Re: directory listing

2005-11-11 Thread Shi Mu
On 11/11/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > "Shi Mu" wrote: > > > but i am curious why the line of "print x" does not show > > anything. > > because your c:\temp directory is empty ? > > print buildList() gets lots of stuffs from my temp directory(there do exist lots of files). But why

Re: directory listing

2005-11-11 Thread Fredrik Lundh
"Shi Mu" wrote: > but i am curious why the line of "print x" does not show > anything. because your c:\temp directory is empty ? -- http://mail.python.org/mailman/listinfo/python-list

Re: directory listing

2005-11-11 Thread Shi Mu
On 11/11/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Shi Mu wrote: > > > I tried this and no error reported but nothing appear on the console, why? > > > > import os > > > > def buildList( directory='c:\TEMP' ): > > dirs = [ ] > > listing = os.listdir(directory) > > for x in listing:

Re: directory listing

2005-11-11 Thread Fredrik Lundh
Shi Mu wrote: > I tried this and no error reported but nothing appear on the console, why? > > import os > > def buildList( directory='c:\TEMP' ): > dirs = [ ] > listing = os.listdir(directory) > for x in listing: > x = os.path.join(directory, x) > print x > if

Re: directory listing

2005-11-11 Thread Shi Mu
On 11 Nov 2005 22:00:04 GMT, Michael Konrad <[EMAIL PROTECTED]> wrote: > Richard Townsend <[EMAIL PROTECTED]> wrote: > > > On 11 Nov 2005 21:20:33 GMT, SU News Server wrote: > > > > Try passing the full pathname of each item to os.path.isdir() > > > > You can create the pathname using os.path.join(

Re: directory listing

2005-11-11 Thread Fredrik Lundh
Michael Konrad wrote: > > for x in listing: > > print x > > if os.path.isdir(x): > > dirs.append(x) > > > > Did that and I was just getting a bunch of [ ]. if you printed "x" (the filename), that doesn't sound very likely. maybe you printed some other variable? (l

Re: directory listing

2005-11-11 Thread Richard Townsend
On 11 Nov 2005 22:00:04 GMT, Michael Konrad wrote: > Richard Townsend <[EMAIL PROTECTED]> wrote: > >> On 11 Nov 2005 21:20:33 GMT, SU News Server wrote: >> >> Try passing the full pathname of each item to os.path.isdir() >> >> You can create the pathname using os.path.join(directory, x) >> >>

Re: directory listing

2005-11-11 Thread Michael Konrad
Richard Townsend <[EMAIL PROTECTED]> wrote: > On 11 Nov 2005 21:20:33 GMT, SU News Server wrote: > > Try passing the full pathname of each item to os.path.isdir() > > You can create the pathname using os.path.join(directory, x) > > > I wonder if I can join ./, so I don't have the full path

Re: directory listing

2005-11-11 Thread Michael Konrad
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote: > "SU News Server" <[EMAIL PROTECTED]> wrote: > >> I've struggled with this for quite a while and I'm am just not sure >> what is going on. I have the following code >> import os >> >> def buildList( directory='/Users/mkonrad' ) >> >> dirs = [ ] >> >> l

Re: directory listing

2005-11-11 Thread Richard Townsend
On 11 Nov 2005 21:20:33 GMT, SU News Server wrote: Try passing the full pathname of each item to os.path.isdir() You can create the pathname using os.path.join(directory, x) -- Richard -- http://mail.python.org/mailman/listinfo/python-list

Re: directory listing

2005-11-11 Thread Fredrik Lundh
"SU News Server" <[EMAIL PROTECTED]> wrote: > I've struggled with this for quite a while and I'm am just not sure > what is going on. I have the following code > import os > > def buildList( directory='/Users/mkonrad' ) > > dirs = [ ] > > listing = os.listdir(directory) > > for x in listing: >

directory listing

2005-11-11 Thread SU News Server
I've struggled with this for quite a while and I'm am just not sure what is going on. I have the following code import os def buildList( directory='/Users/mkonrad' ) dirs = [ ] listing = os.listdir(directory) for x in listing: if os.path.isdir(x):

directory listing

2005-01-27 Thread Atul Kamat
hi how do i get a full listing of permissions for files and directories in linux? Something like rwx-r--r-- i have managed to get it using the os.access modes as of now but it gives me the permissions of the current user. regards Atul Kamat Visionael Labs Bangalore -- http://mail.python.