[Python-ideas] Pre-PEP Adding A Secrets Module To The Standard Library
Chris Angelico
rosuav at gmail.com
Sun Sep 20 02:27:42 CEST 2015
On Sun, Sep 20, 2015 at 10:19 AM, Tim Peters <tim.peters at gmail.com> wrote:
> [Chris Angelico <rosuav at gmail.com>]
>> token_bytes "obviously" should return a bytes,
>
> Which os.urandom() does in Python 3. I'm not writing docs, just
> suggesting the functions.
>
>> and token_alpha equally obviously should be returning a str.
>
> Which part of "string" doesn't suggest "str"?
>
>> (Or maybe it should return the same type as alphabet, which
>> could be either?)
>>
>>: What about the other two?
>
> Which part of "ASCII" is ambiguous?
>
>> Also, if you ask for 4 bytes from token_hex, do you get 4 hex
>> digits or 8 (four bytes of entropy)?
>
> And which part of "same"? ;-)
>
> Bikeshed away.; I'm outta this now ;-)
Heh :)
My personal preference for shed colour: token_bytes returns a
bytestring, its length being the number provided. All the others
return Unicode strings, their lengths again being the number provided.
So they're all text bar the one that explicitly says it's in bytes.
But I'm aware others may disagree, and while "ASCII" might not be
ambiguous, Py3 does still distinguish between b"asdf" and u"asdf" :)
ChrisA
More information about the Python-ideas
mailing list