mapLast, mapFirst, and just general iterator questions

Greg Ewing greg.ewing at canterbury.ac.nz
Tue Jun 14 19:45:32 EDT 2022


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, because it ties it together
visually and lets me have locals that are properly local.

If the file is only ever used as a script, I just put an unconditional
call to the main function at the bottom.

-- 
Greg


More information about the Python-list mailing list