Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #198061
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | ram@zedat.fu-berlin.de (Stefan Ram) |
| Newsgroups | comp.lang.python |
| Subject | Re: ''.join([bin(i)[2:].zfill(8) for i in flag]) |
| Date | 23 Sep 2026 23:09:14 GMT |
| Organization | Stefan Ram |
| Lines | 21 |
| Expires | 1 Sep 2027 11:59:58 GMT |
| Message-ID | <bin-20260924000855@ram.dialup.fu-berlin.de> (permalink) |
| References | <nnd$45c195ac$47172e6f@35c50d4e9a8c02a9> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 8bit |
| X-Trace | news.uni-berlin.de lleePlc5ODhnCIuyJIX0/wMa30lunSPmY8xBHCFxVZeaQj |
| Cancel-Lock | sha1:+EEkQKOXyx0Ixw00vs/GPaMblsc= sha256:TQjf8OvOpdy3sDEiJAX8cDm9otOvUmSGuodyfUq5gi0= |
| X-Copyright | (C) Copyright 2026 Stefan Ram. All rights reserved. Distribution through any means other than regular usenet channels is forbidden. It is forbidden to publish this article in the Web, to change URIs of this article into links, and to transfer the body without this notice, but quotations of parts in other Usenet posts are allowed. |
| X-No-Archive | Yes |
| Archive | no |
| X-No-Archive-Readme | "X-No-Archive" is set, because this prevents some services to mirror the article in the web. But the article may be kept on a Usenet archive server with only NNTP access. |
| X-No-Html | yes |
| Content-Language | en |
| Xref | csiph.com comp.lang.python:198061 |
Show key headers only | View raw
Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> wrote or quoted:
>As the topic says, is
> ''.join([bin(i)[2:].zfill(8) for i in flag])
>really the most Pythonic way to do this?
. . .
>I mean, isn't there a regular print-to-string-format function, something
>akin to C's sprintf(), that does this in a more succinct way?
Like,
''.join( f'{i:08b}' for i in flag )
?
>Here, `flag` is a string variable, if it's not clear from the con-
>text.
If "flag" would be a string, then "i" would be a string too,
but "bin" expects an integer.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
''.join([bin(i)[2:].zfill(8) for i in flag]) Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-09-24 06:42 +0800
Re: ''.join([bin(i)[2:].zfill(8) for i in flag]) ram@zedat.fu-berlin.de (Stefan Ram) - 2026-09-23 23:09 +0000
Re: format_binary Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-09-24 02:01 +0000
Re: format_binary Jon Ribbens <jon+usenet@unequivocal.eu> - 2026-09-24 06:57 +0000
Re: ''.join([bin(i)[2:].zfill(8) for i in flag]) Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-09-25 23:25 +0800
csiph-web