Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: INADA Naoki Newsgroups: comp.lang.python Subject: Re: [Not actually OT] Trouble in node.js land Date: Wed, 23 Mar 2016 11:06:00 +0000 Lines: 22 Message-ID: References: <56f25be6$0$2805$c3e8da3$76491128@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de zPDThXyj9B940pV21G8FbAtlogXuDkpCcNdrQvlmUNkA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:: [': 0.03; 'received:209.85.223': 0.03; '-1;': 0.09; 'len,': 0.09; 'python': 0.10; ':-)': 0.12; '>>>': 0.15; '!==': 0.16; '&&': 0.16; '(str,': 0.16; 'len': 0.16; 'len)': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:Not': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'translation': 0.16; '<': 0.18; 'subject:] ': 0.19; '>>>': 0.20; 'to:2**1': 0.21; 'leave': 0.23; 'header:In-Reply-To:1': 0.24; 'message- id:@mail.gmail.com': 0.27; 'var': 0.27; 'function': 0.28; 'str': 0.29; 'received:google.com': 0.35; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'skip:& 10': 0.37; 'received:209': 0.38; 'to:addr:python.org': 0.40; 'experts': 0.70 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=lgjTzp3dzyxA4GqfO7KgaHfREX48XvwqzeXIcrxtASU=; b=GuCh+fxoGUzRYKBxnDdTVkHNpTh9ly0zAcw/NLeyr9RxxkDHMhNrEbZ2NQVHyoh5Uo KvUYfsP9oJH3QxgekvxhKH541Nd7vRxGBxqI1RFc9N5VXHvhDbVqjpJ1GnbF82DQe3VB YmgvVrlAIXi6CvBeFPAaOz2V8vAb4jJ7szdOLsqwWAuncqfg5G6REzWyFiHj+Ap5pRcN Dpt0fB7SpSWDazkicqGDFC7DrnnH7fslQS4blw47HmtWFFmz/7TeNQyloxtCY2DwbUiO MpyZ2yFx+NhH+wrhbxvhYcRWnDgtaYGLQgv1sfeAlAOzxYv2icBno7UDX4bF3MVQxxnz 0Okw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=lgjTzp3dzyxA4GqfO7KgaHfREX48XvwqzeXIcrxtASU=; b=dW/fV0X7kLkKe+1EFcfKxJp34OR/ykYR4N+gIaC3PfrRE4wqFEoH5b+U6OP4XZCv04 q7mKl/zQ5ULmb57lu2mHiChjzbuwBXspF/DqsS5oReBG67TKyo8VFrKpJPvOOyCHD0sw NGqdxMGJbmrmMRfJoz//wGZ/XqgcPQbXtqLxwPejb5uMmZWDlf/CAUl+zI/BRAE8wyCI jKmhBERsDIGsbWTuJ/3mNmQ+AEeFa3SEzYM8sXGf2yejoEYPLoDYWfhKd9mSm9X+i+DA rNTXKPm4+zwOUYK3Ar6jYokdKABDbD8i1uT0lZtOIwAm+eTX4lDjUnK+1XoJa4L+EZdA To6A== X-Gm-Message-State: AD7BkJJhvMODIsAouLcj7lemrtyjJE1fHT2OntA6U8BPx6nIAPUj5AGKDDQcrtLalDCbUvJ+sxKrw9MCf6WBjQ== X-Received: by 10.107.8.30 with SMTP id 30mr2919014ioi.60.1458731170328; Wed, 23 Mar 2016 04:06:10 -0700 (PDT) In-Reply-To: <56f25be6$0$2805$c3e8da3$76491128@news.astraweb.com> X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:105539 > > > 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'