Monday, October 17, 2016

Python retains the c-like formatter

It is how the % (or some other char) defines as a substitution mark. Hence the programmer canformat a set of variables into a string, setting field sizes and number formats.

print("Start %s  %d kg!" % ('Zara', 21) )

Noe, this is Redneck programming in extreme.  Rednecks use sprintf in c:

printf(Result_string,format_sting,v1,v2...)

And we keep a prepared list of format string.  So you could always select the particular format you need, for debug dsplays, or formatting output for another program.  This is a great way to format a text statement for submission in the exec(line_string) function.  I dsimplifies some logic, gets me four lines saved in the redneck debugger.
It is a pay off, I get enough lines to add intelligence into the source text window.  Highlight the break points and current line counter.  Use the scrolls function to move the source around.  I can expand that capability a bit, and with the simple highlighting, the code structure is more visible.

No comments: