Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 what could i do with my file tree list generator?
#1
a while back we talked about walking a file tree and i found the function to do that in the Python library had a strange order to it, but the order i wanted was depth first, equivalent to doing a sort of the whole list with "/" being sorted lowest. i ended up writing a generator to do it and yield the whole tree one path at a time, in standard sorted order. i wrote a little command to use it and show that it really works. recently, i added support to accept a key function reference for custom sorting. if that key is given, it sorts the names it gets from each directory, passing that key to the sorted function each time it is called. i wrote a test command for that using a key function that sorts runs of digits as the numeric value, i.e. "foo64bar" will be before "foo1728bar".

what i want to ask is, what kinds of programs/scripts could i write that make use of this generator? i would be especially interested in something that could not be done very well with anything but a generator.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Quote
#2
i am thinking of making an alternate version or an option keyword to do breadth-first ordering. i was doing a manual breadth-first search for something, today, and thought there might be an advantage to having such a tool based on such an iterator.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Quote
#3
i posted the source over in snippets.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Quote
#4
should i add a file name filter, such as re, to my generator, or should that stay outside? is there any example code showing how to stack a generator and a filter (my term for a generator that repeats an iterator given to it and yields selected results from it).
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Quote

Top Page

Forum Jump:


Users browsing this thread: 1 Guest(s)