On Feb 08 2019, Chris Davies <[email protected]> wrote:
> On Tuesday, 5 February 2019 20:42:10 UTC, Nikolaus Rath wrote:
>>
>> So you could probably copy and paste the code elsewhere to get
>> it printed by eg. fsck.
>>
>>
> Stunning, thank you.
>
> Since I'm still learning Python could I ask, please, about this line:
>
> join(split_by_n(b64encode(data_pw).decode(), 4))
>
>
> The join() and split_by_n() are easy enough to follow, as is the base call
> to b64encode(). But where is the .decode() defined, and what is it
> doing?
It turns a sequence of bytes into a string (in this case assuming
us-ascii encoding).
> (In an interactive Python session I couldn't see any difference between
> including it or not; I still got a base64-encoded representation of data_pw
> split
> into four-character segments.)
That's because the interpreter is smart enough to do the conversion
automatically when interactively showing a result.
Best,
-Nikolaus
--
GPG Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F
»Time flies like an arrow, fruit flies like a Banana.«
--
You received this message because you are subscribed to the Google Groups
"s3ql" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.