Dup Ver Goto 📝

PythonIdioms1

PT2/lang/python/old-notes does not exist
To
22 lines, 59 words, 422 chars Page 'PythonIdioms1' does not exist.

{{c def pad(text,length,padstr=' '): 'pads a string with spaces up to a given length, truncates longer strings' if len(padstr) == 0: raise ValueError("pad string cannot be empty") return (text + (padstr*length))[:length]

}}

=== Destructuring Arrays {{c a, b = [1,2] }} Dicts {{c from operator import itemgetter

p = {'a': 1, 'b': 2

a, b = itemgetter('a', 'b')(p) }}}%TIME=1623958486