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.
| Sysop: | Jacob Catayoc |
|---|---|
| Location: | Pasay City, Metro Manila, Philippines |
| Users: | 5 |
| Nodes: | 4 (0 / 4) |
| Uptime: | 498677:07:37 |
| Calls: | 212 |
| Calls today: | 3 |
| Files: | 910 |
| D/L today: |
31 files (22,593K bytes) |
| Messages: | 69,826 |