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


Groups > comp.lang.python > #78102

Re: pad binary string with a given byte value (python 3)

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <gandalf@shopzeus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.066
X-Spam-Evidence '*H*': 0.87; '*S*': 0.00; 'clean.': 0.09; 'subject:string': 0.09; 'def': 0.12; 'mailscanner,': 0.16; 'subject:python': 0.16; 'header:User-Agent:1': 0.23; 'header:In- Reply-To:1': 0.27; 'scanned': 0.29; '>>>>': 0.31; 'thanks!': 0.32; 'subject: (': 0.35; 'subject:with': 0.35; 'believed': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'dangerous': 0.60; 'length': 0.61; 'viruses': 0.61; 'from:charset:utf-8': 0.61
Date Sat, 20 Sep 2014 14:21:50 +0200
From Nagy László Zsolt <gandalf@shopzeus.com>
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0
MIME-Version 1.0
To python-list@python.org
Subject Re: pad binary string with a given byte value (python 3)
References <541D5025.4070604@shopzeus.com> <lvjqin$4ln$1@ger.gmane.org>
In-Reply-To <lvjqin$4ln$1@ger.gmane.org>
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-shopzeus-MailScanner-Information Please contact the ISP for more information
X-shopzeus-MailScanner-ID ECEBA8897398.ADCE1
X-shopzeus-MailScanner Found to be clean
X-shopzeus-MailScanner-From gandalf@shopzeus.com
X-Spam-Status No
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.14165.1411215717.18130.python-list@python.org> (permalink)
Lines 14
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1411215717 news.xs4all.nl 2950 [2001:888:2000:d::a6]:52458
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:78102

Show key headers only | View raw


> bytes/str.ljust()
>
>>>> def pad(b, n=16, c=b"\x0f"):
> ...     length = (len(b)+n-1)//n*n
> ...     return b.ljust(length, c)
Thanks!


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

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


Thread

Re: pad binary string with a given byte value (python 3) Nagy László Zsolt <gandalf@shopzeus.com> - 2014-09-20 14:21 +0200

csiph-web