[Tutor] Beginners question

Mats Wichmann mats at wichmann.us
Wed Apr 1 10:05:30 EDT 2020


On 3/31/20 4:37 PM, DL Neil via Tutor wrote:

> Earlier, I opined that the first code-snippet is "untidy".

curious: why?

> Has such become liable to a similar judgment in deciding whether, for
> example; a complex list-comprehension expression should be coded in its
> compact form, or broken-out into a more readable for-loop?
> (particularly when dealing with lesser-mortals such as I).

there's no question there are tradeoffs.  a compact expression may have
many advantages, for example more of the surrounding code can be seen in
a viewable size snippet (you can make your terminal emulator or editor
window able to show 100 lines, but the brain is going to want to "see" a
much smaller chunk), making it easier to understand the code flow of the
whole chunk, rather than just thinking about the readability of that one
statement-or-expanded-out-loop piece.  or, it may make it harder for the
reader to comprehend because the statement becomes hard to read. "style
dogma" is a thing, but there are no hard and fast answers in the end.

> What more could we do?
> 
> - users may have become habituated to typing "semaphores" such as "quit"
> to end input. However, Python allows considerable flexibility over
> previous generations of languages. Could we instead invite the user to
> hit Enter (with no data)?

sure you can, but this is an interface design decision.  A lot of
developers prefer to have a specific positive value in order to do
something significant... easy to hit Enter without really thinking about
it, but typing "quit" requires clear intent.  That's not really a
"programming" question, we programmers can make it work any way.



More information about the Tutor mailing list