Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #105539

Re: [Not actually OT] Trouble in node.js land

From INADA Naoki <songofacandy@gmail.com>
Newsgroups comp.lang.python
Subject Re: [Not actually OT] Trouble in node.js land
Date 2016-03-23 11:06 +0000
Message-ID <mailman.47.1458731200.2244.python-list@python.org> (permalink)
References <56f25be6$0$2805$c3e8da3$76491128@news.astraweb.com>

Show all headers | View raw


>
>
> 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'

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[Not actually OT] Trouble in node.js land Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-03-23 20:03 +1100
  Re: [Not actually OT] Trouble in node.js land INADA Naoki <songofacandy@gmail.com> - 2016-03-23 11:06 +0000
  Re: [Not actually OT] Trouble in node.js land Random832 <random832@fastmail.com> - 2016-03-23 09:33 -0400
    Re: [Not actually OT] Trouble in node.js land Steven D'Aprano <steve@pearwood.info> - 2016-03-24 01:52 +1100
      Re: [Not actually OT] Trouble in node.js land Random832 <random832@fastmail.com> - 2016-03-23 11:26 -0400
      Re: [Not actually OT] Trouble in node.js land Ben Finney <ben+python@benfinney.id.au> - 2016-03-24 09:09 +1100
  Re: [Not actually OT] Trouble in node.js land Terry Reedy <tjreedy@udel.edu> - 2016-03-23 14:08 -0400
  Re: [Not actually OT] Trouble in node.js land Ethan Furman <ethan@stoneleaf.us> - 2016-03-23 11:23 -0700

csiph-web