> > > For those curious, here's left-pad in all its glory: > > module.exports = leftpad; > function leftpad (str, len, ch) { > str = String(str); > var i = -1; > if (!ch && ch !== 0) ch = ' '; > len = len - str.length; > while (++i < len) { > str = ch + str; > } > return str; > } > > I leave a Python translation for the experts :-) > > >>> s = "foo" >>> s.rjust(5, '@') '@@foo' -- https://mail.python.org/mailman/listinfo/python-list
- [Not actually OT] Trouble in node.js land Steven D'Aprano
- Re: [Not actually OT] Trouble in node.js land INADA Naoki
- Re: [Not actually OT] Trouble in node.js land Random832
- Re: [Not actually OT] Trouble in node.js land Steven D'Aprano
- Re: [Not actually OT] Trouble in node.js land Terry Reedy
- Re: [Not actually OT] Trouble in node.js land Ethan Furman