On Tue, Mar 23, 2021 at 10:40:01AM -0400, Avi Gross via Python-list wrote: > Alberto, > [...] > I am a tod concerned as to where any of the variables x, y or z have been > defined at this point. I have not seen a BEGIN {...} pattern/action or > anywhere these have been initialized but they are set in a function that as > far as I know has not been called. Weird. Maybe awk is allowing an > uninitialized variable to be tested for in your code but if so, you need to > be cautious how you do this in python.
As far as I can say, the type of uninitialised variable is groked from the first operation on it. I.e., "count += 1" first initializes count to 0 and then adds 1. This might depend on exact awk being used. There were few of them during last 30+ years. I just assume it does as I wrote above. Using BEGIN would be in better style, of course. There is a very nice book, "The AWK Programming Language" by Aho, Kernighan and Weinberger. First printed in 1988, now free and in pdf format. Go search. Perhaps it is easier to make the script work rather than rewriting it in another language. Both ways require deep understanding of current code, then with rewrite one also has to make sure new code is drop in replacement for the old. There is very nice documentation to gawk (Gnu AWK). -- Regards, Tomasz Rola -- ** A C programmer asked whether computer had Buddha's nature. ** ** As the answer, master did "rm -rif" on the programmer's home ** ** directory. And then the C programmer became enlightened... ** ** ** ** Tomasz Rola mailto:tomasz_r...@bigfoot.com ** -- https://mail.python.org/mailman/listinfo/python-list