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
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
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)
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
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
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
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
"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 =
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
"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
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:
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
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(
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
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)
>>
>>
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
"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
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
"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:
>
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):
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.
21 matches
Mail list logo