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
On 16.03.2011 20:41, dude wrote: My goal is create a list of absolute paths for all files in a given directory (any number of levels deep). root dir1 file1 file2 dir2 file3 dir3 -dir4 --file4 file5 So the above woul

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
On Jun 5, 4:54 pm, Jeff Nyman <[EMAIL PROTECTED]> wrote: > The problem is that my code grabs every single directory that is > under the various city directories when what I really want it to do is > just grab the directories that are under Sites\ and that's it. I don't > want it to recurse down int

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\\Flex\\Sites', walker1, 0

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\\Flex\\Sites', walker1,

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(dir_name, selector, None) >

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(dir_name, selector, None) >

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

2007-05-28 Thread Gabriel Genellina
En Mon, 28 May 2007 05:25:18 -0300, Maric Michaud <[EMAIL PROTECTED]> escribió: > Gabriel Genellina a écrit : >> - iterate backwards: >> >> for i in range(len(names)-1, -1, -1): >>fname = names[i] >>if fname[:1]=='.': >> names.remove(fname) >> > > This is not about iterating backwar

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
En Sun, 27 May 2007 22:39:32 -0300, Joe Ardent <[EMAIL PROTECTED]> escribió: > Good day, everybody! From what I can tell from the archives, this is > everyone's favorite method from the standard lib, and everyone loves > answering questions about it. Right? :) Well, in fact, the preferred (and

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

2007-05-27 Thread Peter Otten
Joe Ardent wrote: > Good day, everybody! From what I can tell from the archives, this is > everyone's favorite method from the standard lib, and everyone loves > answering questions about it. Right? :) I don't know what to make of the smiley, so I'll be explicit: use os.walk() instead of os.pat

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, I guess is that the OP c

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.walk but use os.

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() instead... -P

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(name, processDir

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, processDirectory(a,b,