On 18/12/05, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Ed Singleton wrote:
> > Is it possible to access the next and previous items during an iteration?
>
> This just came up on c.l.python. Bengt Richter has a nice generator-based
> solution.
> http://groups.google.com/group/comp.lang.python/brows
Ed Singleton wrote:
> Is it possible to access the next and previous items during an iteration?
This just came up on c.l.python. Bengt Richter has a nice generator-based
solution.
http://groups.google.com/group/comp.lang.python/browse_thread/thread/2e4533f108fbf172/90d87c91dac844d3?hl=en#90d87c91
Chris or Leslie Smith wrote:
> I just did this :-) What I did was
>
> 1) use the glob module to get a list of the files in the directory (*.htm)
> 2) sort this using a special sort function (in my case the files were named
> as #_# where # was a number and I wanted to sort according to the first
| Is it possible to access the next and previous items during an
| iteration?
|
| I want to use it to iterate through html files in a folder and add
| links in to the next and previous pages.
|
I just did this :-) What I did was
1) use the glob module to get a list of the files in the directory
| Is it possible to access the next and previous items during an
| iteration?
|
| I want to use it to iterate through html files in a folder and add
| links in to the next and previous pages.
|
I just did this :-) What I did was
1) use the glob module to get a list of the files in the directory
| Is it possible to access the next and previous items during an
| iteration?
|
| I want to use it to iterate through html files in a folder and add
| links in to the next and previous pages.
|
I just did this :-) What I did was
1) use the glob module to get a list of the files in the directory
Ed Singleton wrote:
> Is it possible to access the next and previous items during an iteration?
There is nothing built in to support this directly.
> I'm currently using:
>
> prev = 0
> current = 0
> next = 0
> for page in folder:
> prev = current
> current = next
> next = page
Is it possible to access the next and previous items during an iteration?
I want to use it to iterate through html files in a folder and add
links in to the next and previous pages.
For example
for page in folder:
#add link to previous page
#add link to next page
I'm currently using:
p