Re: os.path.walk() to get full path of all files

2011-03-17 Thread Jussi Piitulainen
Laurent Claessens writes: > > file_list = [] > > for root, _, filenames in os.walk(root_path): > > for filename in filenames: > > file_list.append(os.path.join(root, filename)) > > What does the notation "_" stands for ? Is it a sort of /dev/null ? >>> x, _, y = 1, "hukairs",

Re: os.path.walk() to get full path of all files

2011-03-17 Thread Tim Golden
On 17/03/2011 08:58, Laurent Claessens wrote: file_list = [] for root, _, filenames in os.walk(root_path): for filename in filenames: file_list.append(os.path.join(root, filename)) What does the notation "_" stands for ? Is it a sort of /dev/null ? I know that in the terminal it represents

Re: os.path.walk() to get full path of all files

2011-03-17 Thread Laurent Claessens
file_list = [] for root, _, filenames in os.walk(root_path): for filename in filenames: file_list.append(os.path.join(root, filename)) What does the notation "_" stands for ? Is it a sort of /dev/null ? I know that in the terminal it represents the last printed text. Laurent

Re: os.path.walk() to get full path of all files

2011-03-16 Thread Alexander Kapps
On 16.03.2011 22:00, dude wrote: awesome, that worked. I'm not sure how the magic is working with your underscores there, but it's doing what I need. thanks. The underscore is no magic here. It's just a conventional variable name, saying "I m unused". One could also write: for root, UNUSE

Re: os.path.walk() to get full path of all files

2011-03-16 Thread Benjamin Kaplan
On Wed, Mar 16, 2011 at 5:00 PM, dude wrote: > awesome, that worked.  I'm not sure how the magic is working with your > underscores there, but it's doing what I need.  thanks. > -- It's not magic at all. _ is just a variable name. When someone names a variable _, it's just to let you know that t

Re: os.path.walk() to get full path of all files

2011-03-16 Thread dude
awesome, that worked. I'm not sure how the magic is working with your underscores there, but it's doing what I need. thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: os.path.walk() to get full path of all files

2011-03-16 Thread Alexander Kapps
would return: [root/dir1/file1, root/dir1/file2, root/dir1/dir2/file3, etc...] I've been trying different ways of using os.path.walk() for that, but I can't find an elegant way. Anyone know of something simple to accomplish that? Try this: file_list = [] for root, _, filenames in os.walk

os.path.walk() to get full path of all files

2011-03-16 Thread dude
/dir1/file2, root/dir1/dir2/file3, etc...] I've been trying different ways of using os.path.walk() for that, but I can't find an elegant way. Anyone know of something simple to accomplish that? -- http://mail.python.org/mailman/listinfo/python-list

Re: problem with running os.path.walk()

2009-10-13 Thread Gabriel Genellina
* 60 * 60) for filename in filenames : stats = os.stat(dirname + os.sep + filename) modified = stats[8] if modified >= cutoff : print dirname + os.sep + filename os.path.walk('C:\\windows\\system',walker2,30) if

problem with running os.path.walk()

2009-10-13 Thread MalC0de
filenames : stats = os.stat(dirname + os.sep + filename) modified = stats[8] if modified >= cutoff : print dirname + os.sep + filename os.path.walk('C:\\windows\\system',walker2,30) if I have problem with it then let me know and if

Re: os.path.walk -- Can You Limit Directories Returned?

2008-06-05 Thread Jeff Nyman
Thank you to everyone for your help. Much appreciated. I now have a better understanding of how glob can be used and I have a much better understanding of using the more effective os.walk. - Jeff -- http://mail.python.org/mailman/listinfo/python-list

Re: os.path.walk -- Can You Limit Directories Returned?

2008-06-05 Thread alex23
> want it to recurse down into the sub-directories of the cities. > > Is there a way to do this? Or is os.path.walk not by best choice here? No, os.path.walk will always recurse through all of the sub, that's its purpose. os.walk produces a generator, which you can then manually st

Re: os.path.walk -- Can You Limit Directories Returned?

2008-06-05 Thread Gary Herron
Jeff Nyman wrote: Greetings all. I did some searching on this but I can't seem to find a specific solution. I have code like this: = def walker1(arg, dirname, names): DC_List.append((dirname,'')) os.path.walk('vcdcflx006\\F

Re: os.path.walk -- Can You Limit Directories Returned?

2008-06-05 Thread Diez B. Roggisch
Jeff Nyman schrieb: Greetings all. I did some searching on this but I can't seem to find a specific solution. I have code like this: = def walker1(arg, dirname, names): DC_List.append((dirname,'')) os.path.walk('vcdcflx006\\F

os.path.walk -- Can You Limit Directories Returned?

2008-06-04 Thread Jeff Nyman
Greetings all. I did some searching on this but I can't seem to find a specific solution. I have code like this: = def walker1(arg, dirname, names): DC_List.append((dirname,'')) os.path.walk('vcdcflx006\\Flex

Re: Unable to write output from os.path.walk to a file.

2008-06-04 Thread Jeff McNeil
Your args are fine, that's just the way os.path.walk works. If you just need the absolute pathname of a directory when given a relative path, you can always use os.path.abspath, too. A couple more examples that may help, using os.walk: >>> for i in os.walk('/var/log'

Re: Unable to write output from os.path.walk to a file.

2008-06-04 Thread Paul Lemelle
/08, Jeff McNeil <[EMAIL PROTECTED]> wrote: > From: Jeff McNeil <[EMAIL PROTECTED]> > Subject: Re: Unable to write output from os.path.walk to a file. > To: [EMAIL PROTECTED] > Cc: python-list@python.org > Date: Wednesday, June 4, 2008, 3:26 PM > What exactly are you t

Re: Unable to write output from os.path.walk to a file.

2008-06-04 Thread Jeff McNeil
What exactly are you trying to accomplish? If you're just looking for the contents of a directory, it would be much easier to simply call os.listdir(dirinput) as that will return a list of strings that represent the entries in dirinput. As it stands, 'os.path.walk' will retu

Re: Unable to write output from os.path.walk to a file.

2008-06-04 Thread Larry Bates
Paul Lemelle wrote: I Am trying to output the os.path.walk to a file, but the writelines method complains Below is the code, any helpful suggestions would be appreciated. def visit(arg, dirnames, names): print dirnames dirinput = raw_input("Enter directory to

Unable to write output from os.path.walk to a file.

2008-06-04 Thread Paul Lemelle
I Am trying to output the os.path.walk to a file, but the writelines method complains Below is the code, any helpful suggestions would be appreciated. def visit(arg, dirnames, names): print dirnames dirinput = raw_input("Enter directory to read: "

Re: os.path.walk usage on WinXP

2007-07-26 Thread Alex Popescu
Alex Popescu <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Hi all! > > I am trying to use the os.path.walk function, but I am getting a weird > error: > > def _walk(dir_name): > def selector(arg, dirname, fnames): > print "selector" >

Re: os.path.walk usage on WinXP

2007-07-26 Thread Alex Popescu
Alex Popescu <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Hi all! > > I am trying to use the os.path.walk function, but I am getting a weird > error: > > def _walk(dir_name): > def selector(arg, dirname, fnames): > print "selector" >

os.path.walk usage on WinXP

2007-07-26 Thread Alex Popescu
Hi all! I am trying to use the os.path.walk function, but I am getting a weird error: def _walk(dir_name): def selector(arg, dirname, fnames): print "selector" os.path.walk(dir_name, selector, None) File "C:\zengarden\python\python25\lib\ntpath.py", line 3

Re: os.path.walk not pruning descent tree (and I'm not happy with that behavior?)

2007-05-28 Thread Gabriel Genellina
reassign in place > > Seems the best here. > >> (the [:] is important): > > Not so. Unless "names" is referenced in another namespace, simple > assignment is enough. But this is exactly the case; the visit function is called from inside the os.path.walk code, a

Re: os.path.walk not pruning descent tree (and I'm not happy with that behavior?)

2007-05-28 Thread Maric Michaud
I'm really sorry, for all that private mails, thunderbird is awfully stupid dealing with mailing lists folder. Gabriel Genellina a écrit : > En Sun, 27 May 2007 22:39:32 -0300, Joe Ardent <[EMAIL PROTECTED]> escribió: > > > - iterate backwards: > > for i in range(len(names)-1, -1, -1): >f

Re: os.path.walk not pruning descent tree (and I'm not happy with that behavior?)

2007-05-27 Thread Gabriel Genellina
, the preferred (and easier) way is to use os.walk - but os.path.walk is fine too. > Anyway, my question regards the way that the visit callback modifies > the names list. Basically, my simple example is: > > ## > def listUndottedDirs( d ): >

Re: os.path.walk not pruning descent tree (and I'm not happy with that behavior?)

2007-05-27 Thread Peter Otten
use os.walk() instead of os.path.walk(). > Anyway, my question regards the way that the visit callback modifies > the names list. Basically, my simple example is: > > ## > def listUndottedDirs( d ): > dots = re.compile( '\.' ) > >

os.path.walk not pruning descent tree (and I'm not happy with that behavior?)

2007-05-27 Thread Joe Ardent
print "%s: %s" % ( dirname, f ) os.path.walk( d, visit, None ) ### Basically, I don't want to visit any hidden subdirs (this is a unix system), nor am I interested in dot-files. If I call the function like, "listUndottedDirs( '/usr/hom

RE: os.path.walk

2005-04-13 Thread Tony Meyer
> I think if you try this you will find that it doesn't work because > os.path.walk will try to call the *result* of processDirectory(a,b,c) > for each directory in the path. Opps. I missed the "path", so gave an answer for os.walk. Apologies. The actual answer, then

Re: os.path.walk

2005-04-13 Thread Steven Bethard
Peter Hansen wrote: Micheal wrote: If I have os.path.walk(name, processDirectory, None) and processDirectory needs three arguments how can I ass them because walk only takes 3? The best answer to this is: if you aren't stuck using a version of Python prior to 2.4, don't use os.path.wa

Re: os.path.walk

2005-04-13 Thread Peter Hansen
Micheal wrote: If I have os.path.walk(name, processDirectory, None) and processDirectory needs three arguments how can I ass them because walk only takes 3? The best answer to this is: if you aren't stuck using a version of Python prior to 2.4, don't use os.path.walk but use os.walk

Re: os.path.walk

2005-04-13 Thread Steve Holden
Tony Meyer wrote: If I have os.path.walk(name, processDirectory, None) and processDirectory needs three arguments how can I ass them because walk only takes 3? Assuming that processDirectory is a function of yours that returns a bool, then you'd do something like: os.path.walk

RE: os.path.walk

2005-04-12 Thread Tony Meyer
> If I have os.path.walk(name, processDirectory, None) and > processDirectory needs three arguments how can I ass them > because walk only takes 3? Assuming that processDirectory is a function of yours that returns a bool, then you'd do something like: os.path.walk(name, proces

os.path.walk

2005-04-12 Thread Micheal
If I have os.path.walk(name, processDirectory, None) and processDirectory needs three arguments how can I ass them because walk only takes 3? -- http://mail.python.org/mailman/listinfo/python-list