Python Forum
what could i do with my file tree list generator?
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.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#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.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#3
i posted the source over in snippets.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#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).
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020