Python has this elegant destructuring-assignment iterable-unpacking syntax that every serious Pythonista and her dog tends to use whereëver possible. So where a novice might write
split_address = address.split(':')
host = split_address
port = split_address
a serious Pythonista (and her dog) would instead say
host, port = address.split(':')
which is clearly superior on grounds of succinctness and beauty; we don't want our vision to be cluttered with this ugly sub-zero, sub-one notation when we can just declare a sequence of names.
Consider, however, the somewhat-uncommon case where we have an iterable that, for whatever reason, we happen to know contains only one element, and we want to assign that one element to a variable. Here, I've seen people who ought to know better fall back to indexing:
if len(jobs) == 1:
job = jobs
But there's no reason to violate the æsthetic principle of "use a length-n (or smaller) tuple of identifiers on the left side of a destructuring assignment in order to name the elements of a length-n iterable" just because n happens to be one:
if len(jobs) == 1:
job, = jobs
I'm pleased to introduce the five of you to start off the App Academy mentorship program. Zack -- meet [redacted 1], [redacted 2], [redacted 3], and [redacted 4], your mentees from the March 2016 cohort.
You'll have a chance to meet in person this Thursday at the mentorship kickoff [...] Until then, please send an email introducing yourself to your mentor/mentees, including what you did before App Academy, your favorite part of writing code, and what you like to do for fun (besides writing code).
[...] I think my favorite part of writing code is the vertiginous terror of manifesting machinery out of pure ideas, summoning thought-engines from the underworld with unknown lives and dollars hanging in the balance and protected only by the clarity of one's understanding, and the clarity of understanding of the ones who wrote the tools built on tools built on tools extending thirty layers deep into the underworld on which the fictive ontology of our existence carefully rests, praying that the test suite is comprehensive, knowing that it isn't, hoping that the fullness of your thought in its obvious righteousness doesn't need it and that the customers and investors and hypothetical ascended children's children's children would smile on this moment, judging that you have brought honor to this endeavor, the last human profession.
I would like to be able to tell you what I did before App Academy, but unfortunately, everything in my life before December 2013 is non-canon. Similarly what I do for fun. In any case, I have the honor to be,
Your obedient servant,
Zack M. Davis