Re: mapLast, mapFirst, and just general iterator questions

2022-06-14 Thread Cameron Simpson
On 15Jun2022 05:49, Chris Angelico wrote: >On Wed, 15 Jun 2022 at 05:45, Roel Schroeven wrote: >> Not (necessarily) a main function, but these days the general >> recommendation seems to be to use the "if __name__ == '__main__':" >> construct, so that the file can be used as a module as well as a

Re: mapLast, mapFirst, and just general iterator questions

2022-06-14 Thread Greg Ewing
On 15/06/22 7:49 am, Chris Angelico wrote: If it does need to be used as a module as well as a script, sure. But (a) not everything does, and (b) even then, you don't need a main() I think this is very much a matter of taste. Personally I find it tidier to put the top level code in a function,

Re: mapLast, mapFirst, and just general iterator questions

2022-06-14 Thread Chris Angelico
On Wed, 15 Jun 2022 at 05:45, Roel Schroeven wrote: > > Chris Angelico schreef op 14/06/2022 om 20:47: > > > def main(): > > > for each in (iterEmpty, iter1, iter2, iterMany): > > > baseIterator = each() > > > chopFirst = mapFirst(baseIterator, lambda x: x[1:-1]) > > >

Re: mapLast, mapFirst, and just general iterator questions

2022-06-14 Thread Roel Schroeven
Chris Angelico schreef op 14/06/2022 om 20:47: > def main(): > for each in (iterEmpty, iter1, iter2, iterMany): > baseIterator = each() > chopFirst = mapFirst(baseIterator, lambda x: x[1:-1]) > andCapLast = mapLast(chopFirst, lambda x: x.upper()) > print(repr("

Re: mapLast, mapFirst, and just general iterator questions

2022-06-14 Thread Chris Angelico
On Wed, 15 Jun 2022 at 04:07, Travis Griggs wrote: > def mapFirst(stream, transform): > try: > first = next(stream) > except StopIteration: > return > yield transform(first) > yield from stream Small suggestion: Begin with this: stream = iter(stream) That way, yo

mapLast, mapFirst, and just general iterator questions

2022-06-14 Thread Travis Griggs
I want to be able to apply different transformations to the first and last elements of an arbitrary sized finite iterator in python3. It's a custom iterator so does not have _reversed_. If the first and last elements are the same (e.g. size 1), it should apply both transforms to the same element

Re: fill out bulletins

2022-06-14 Thread Avi Gross via Python-list
I wish this discussion was simplified. It sounds to me like what is wanted is a way to PRINT a filled-out form using some dynamic text that fits over designated slots in the data. It is not that different from many other tasks where you overlay some graphics with text. You need a decent version o

Re: fill out bulletins

2022-06-14 Thread Dennis Lee Bieber
On Tue, 14 Jun 2022 00:41:07 +0200, jak declaimed the following: >If you are interested in seeing what I called "post office bulletin" >(English is not my language and I don't know the name, sorry), you can >find a sample pdf (fillable) but it works badly here: > >https://www.guardiacostiera.gov.

Re: fill out bulletins

2022-06-14 Thread jak
Il 14/06/2022 15:28, Peter Pearson ha scritto: On Tue, 14 Jun 2022 00:41:07 +0200, jak wrote: [snip] If you are interested in seeing what I called "post office bulletin" (English is not my language and I don't know the name, sorry), you can find a sample pdf (fillable) but it works badly here:

Re: fill out bulletins

2022-06-14 Thread Peter Pearson
On Tue, 14 Jun 2022 00:41:07 +0200, jak wrote: [snip] > > If you are interested in seeing what I called "post office bulletin" > (English is not my language and I don't know the name, sorry), you can > find a sample pdf (fillable) but it works badly here: > > https://www.guardiacostiera.gov.it/ven