diff options
Diffstat (limited to '_modules/alphanum')
| -rw-r--r-- | _modules/alphanum/alphanum.html | 229 |
1 files changed, 229 insertions, 0 deletions
diff --git a/_modules/alphanum/alphanum.html b/_modules/alphanum/alphanum.html new file mode 100644 index 0000000..2da5dd2 --- /dev/null +++ b/_modules/alphanum/alphanum.html @@ -0,0 +1,229 @@ + + +<!DOCTYPE html> +<html class="writer-html5" lang="en" > +<head> + <meta charset="utf-8"> + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>alphanum.alphanum — alphanum 0.2.0 documentation</title> + + + + <link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" /> + <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" /> + + + + + + + + <!--[if lt IE 9]> + <script src="../../_static/js/html5shiv.min.js"></script> + <![endif]--> + + + <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script> + <script src="../../_static/jquery.js"></script> + <script src="../../_static/underscore.js"></script> + <script src="../../_static/doctools.js"></script> + <script src="../../_static/language_data.js"></script> + + <script type="text/javascript" src="../../_static/js/theme.js"></script> + + + <link rel="index" title="Index" href="../../genindex.html" /> + <link rel="search" title="Search" href="../../search.html" /> +</head> + +<body class="wy-body-for-nav"> + + + <div class="wy-grid-for-nav"> + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search" > + + + + <a href="../../index.html" class="icon icon-home" alt="Documentation Home"> alphanum + + + + </a> + + + + + + + +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + + + </div> + + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + + + + <p class="caption"><span class="caption-text">Contents:</span></p> +<ul> +<li class="toctree-l1"><a class="reference internal" href="../../source/modules.html">alphanum</a></li> +</ul> + + + + </div> + + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" aria-label="top navigation"> + + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../index.html">alphanum</a> + + </nav> + + + <div class="wy-nav-content"> + + <div class="rst-content"> + + + + + + + + + + + + + + + + + +<div role="navigation" aria-label="breadcrumbs navigation"> + + <ul class="wy-breadcrumbs"> + + <li><a href="../../index.html" class="icon icon-home"></a> »</li> + + <li><a href="../index.html">Module code</a> »</li> + + <li>alphanum.alphanum</li> + + + <li class="wy-breadcrumbs-aside"> + + </li> + + </ul> + + + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <h1>Source code for alphanum.alphanum</h1><div class="highlight"><pre> +<span></span><span class="k">try</span><span class="p">:</span> + <span class="kn">import</span> <span class="nn">secrets</span> <span class="k">as</span> <span class="nn">random</span> +<span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span> + <span class="kn">import</span> <span class="nn">random</span> +<span class="kn">import</span> <span class="nn">string</span> + +<span class="n">POP</span> <span class="o">=</span> <span class="n">string</span><span class="o">.</span><span class="n">ascii_letters</span> <span class="o">+</span> <span class="n">string</span><span class="o">.</span><span class="n">digits</span> + + +<div class="viewcode-block" id="generate"><a class="viewcode-back" href="../../source/alphanum.html#alphanum.alphanum.generate">[docs]</a><span class="k">def</span> <span class="nf">generate</span><span class="p">(</span><span class="n">length</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">1</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> + <span class="sd">"""Generates a random string of alphanumeric characters of the given length.</span> +<span class="sd"> If no length is specified, a single character is returned.</span> + +<span class="sd"> On Python 3.5, this string is pseudo-randomly generated using</span> +<span class="sd"> :py:mod:`random`. With 3.6 and later, the randomness is generated with</span> +<span class="sd"> :py:mod:`secrets`, making the randomization cryptographically strong.</span> + +<span class="sd"> Args:</span> +<span class="sd"> length (:obj:`int`, optional): Desired string length. Defaults to 1.</span> + +<span class="sd"> Returns:</span> +<span class="sd"> str: A pseudo-random alphanumeric string.</span> + +<span class="sd"> Examples:</span> +<span class="sd"> >>> print(alphanum.generate())</span> +<span class="sd"> 'G'</span> +<span class="sd"> >>> print(alphanum.generate(10))</span> +<span class="sd"> 'a93jfDjdA0'</span> + +<span class="sd"> """</span> + <span class="k">return</span> <span class="s1">''</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">random</span><span class="o">.</span><span class="n">SystemRandom</span><span class="p">()</span><span class="o">.</span><span class="n">choice</span><span class="p">(</span><span class="n">POP</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">length</span><span class="p">))</span></div> +</pre></div> + + </div> + + </div> + <footer> + + + <hr/> + + <div role="contentinfo"> + <p> + + © Copyright 2020, Cody Logan + + </p> + </div> + + + + Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a + + <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> + + provided by <a href="https://readthedocs.org">Read the Docs</a>. + +</footer> + + </div> + </div> + + </section> + + </div> + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.Navigation.enable(true); + }); + </script> + + + + + + +</body> +</html>
\ No newline at end of file |
