On Wednesday, December 6, 2017 at 3:13:41 PM UTC-6, Python wrote: [...] > Geez, seriously? The snippet is purely academic, obviously > not a complete or useful program,
Who ever made the claim that it was? > intended to illustrate that python can take two different > branches depending on whether or not the slicing operation > yeilded a non-empty container, using uncomplicated syntax. > It effectively serves that purpose. "Uncomplicated" is a relative term, not an absolute. The following is Terry's original: if item: process(item) else: do_without_item() And here is the functioning equivalent, sans any fuzzy semantics: if item: process(item) else: pass And finally, here is the functioning equivalent, sans the fuzzy semantics *AND* the forced vist to a little "ghost town". if item: process(item) My point is simple: What good could possibly come from posting bloat-ware example code? The else-clause is superfluous. How many times must i explain this simple concept before you will admit you are wrong? > Moreover, in order for the example to make sense, we must > assume the existence of unspecified code: The variables > need to have been initialized previously, or else the > snippet is non-functional. Agreed. > The if conditional would never be reached. We can as > easily assume that the hypothetical example continues with > other, unspecified code, and that the equally unspecified > do_without_item() actually does something, Fine. Why stop at a single if/else binary? Why not offer N more irrelevant clauses? import os, re value = "foo" if value: do_something1(value) elif isinstance(value, (int, float)): do_something_else1(value) elif os.path.exists(value): do_something_else2(value) elif re.match(r'.*ly', value): do_something_else3(value) else: do_nothing() The possibilities are literally endless. > which renders your argument completely invalid and > pointless. And that's an opinion you get to have. > The whole thing is entirely academic; continuing to argue > this is an utter waste of time and bandwidth. Yet, here you are, apeaking on behalf of others. It boggles the mind. -- https://plus.google.com/u/0/collection/UAv9UE -- https://mail.python.org/mailman/listinfo/python-list