[docs] [issue33430] Import secrets module in secrets examples

Steven D'Aprano report at bugs.python.org
Sat May 5 05:14:29 EDT 2018

Steven D'Aprano <steve+python at pearwood.info> added the comment:

I've always expected that documentation for a module can assume that the module itself, and/or the function being described, has been imported.

On the other hand, I have no objection to making this explicit, especially in the recipes section where it might not be as clear which functions come from the module and which are builtins.

I'm inclined to go for your 2nd option, import the module and use a full-qualified name:

password = ''.join(secrets.choice(alphabet) for i in range(8))

nosy: +steven.daprano

Python tracker <report at bugs.python.org>

More information about the docs mailing list