From 9914e9010c753c23fc7cf96c0de0dd2988b30b92 Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Thu, 23 May 2019 13:20:44 -0400 Subject: [PATCH] Update the docs for removing Python 2 support Some of the example output may still be from Python 2. --- docs/conf.py | 3 +-- docs/language/api.rst | 15 ++------------- docs/language/core.rst | 18 ++---------------- docs/language/internals.rst | 10 ++++------ docs/language/syntax.rst | 12 ++++-------- docs/style-guide.rst | 1 - docs/tutorial.rst | 3 --- 7 files changed, 13 insertions(+), 49 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 682dbcf..f4ae994 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -52,5 +52,4 @@ html_context = dict( hy_descriptive_version = hy_descriptive_version) intersphinx_mapping = dict( - py2 = ('https://docs.python.org/2/', None), - py = ('https://docs.python.org/3/', None)) + py = ('https://docs.python.org/3/', None)) diff --git a/docs/language/api.rst b/docs/language/api.rst index 2a690f6..6b243ba 100644 --- a/docs/language/api.rst +++ b/docs/language/api.rst @@ -564,8 +564,6 @@ requires. File "", line 1, in TypeError: compare() missing 1 required keyword-only argument: 'keyfn' - Availability: Python 3. - &kwargs Like ``&rest``, but for keyword arugments. The following parameter will contain 0 or more keyword arguments. @@ -1057,7 +1055,7 @@ if / if* / if-not ``if / if* / if-not`` respect Python *truthiness*, that is, a *test* fails if it evaluates to a "zero" (including values of ``len`` zero, ``None``, and ``False``), and passes otherwise, but values with a ``__bool__`` method -(``__nonzero__`` in Python 2) can overrides this. +can override this. The ``if`` macro is for conditionally selecting an expression for evaluation. The result of the selected expression becomes the result of the entire ``if`` @@ -1296,19 +1294,12 @@ fact, these forms are implemented as generator functions whenever they contain Python statements, with the attendant consequences for calling ``return``. By contrast, ``for`` shares the caller's scope. -.. note:: An exception to the above scoping rules occurs on Python 2 for - ``lfor`` specifically (and not ``sfor``, ``gfor``, or ``dfor``) when - Hy can implement the ``lfor`` as a Python list comprehension. Then, - variables will leak to the surrounding scope. - nonlocal -------- .. versionadded:: 0.11.1 -**PYTHON 3.0 AND UP ONLY!** - ``nonlocal`` can be used to mark a symbol as not local to the current scope. The parameters are the names of symbols to mark as nonlocal. This is necessary to modify variables through nested ``fn`` scopes: @@ -1693,7 +1684,7 @@ object (respectively) to provide positional or keywords arguments => (f #* [1 2] #** {"c" 3 "d" 4}) [1, 2, 3, 4] -With Python 3, unpacking is allowed in more contexts, and you can unpack +Unpacking is allowed in a variety of contexts, and you can unpack more than once in one expression (:pep:`3132`, :pep:`448`). .. code-block:: clj @@ -2038,8 +2029,6 @@ yield-from .. versionadded:: 0.9.13 -**PYTHON 3.3 AND UP ONLY!** - ``yield-from`` is used to call a subgenerator. This is useful if you want your coroutine to be able to delegate its processes to another coroutine, say, if using something fancy like diff --git a/docs/language/core.rst b/docs/language/core.rst index 7e42691..cabb420 100644 --- a/docs/language/core.rst +++ b/docs/language/core.rst @@ -240,19 +240,6 @@ otherwise ``False``. Return ``True`` if *coll* is empty. True -.. _exec-fn: - -exec ----- - -Equivalent to Python 3's built-in function :py:func:`exec`. - -.. code-block:: clj - - => (exec "print(a + b)" {"a" 1} {"b" 2}) - 3 - - .. _float?-fn: float? @@ -385,8 +372,7 @@ integer? Usage: ``(integer? x)`` -Returns `True` if *x* is an integer. For Python 2, this is -either ``int`` or ``long``. For Python 3, this is ``int``. +Returns `True` if *x* is an integer (``int``). .. code-block:: hy @@ -924,7 +910,7 @@ string? Usage: ``(string? x)`` -Returns ``True`` if *x* is a string. +Returns ``True`` if *x* is a string (``str``). .. code-block:: hy diff --git a/docs/language/internals.rst b/docs/language/internals.rst index 1cd32ad..a89b356 100644 --- a/docs/language/internals.rst +++ b/docs/language/internals.rst @@ -120,9 +120,7 @@ HyString ~~~~~~~~ ``hy.models.HyString`` represents string literals (including bracket strings), -which compile down to unicode string literals in Python. ``HyStrings`` inherit -unicode objects in Python 2, and string objects in Python 3 (and are therefore -not encoding-dependent). +which compile down to unicode string literals (``str``) in Python. ``HyString``\s are immutable. @@ -140,15 +138,15 @@ HyBytes ~~~~~~~ ``hy.models.HyBytes`` is like ``HyString``, but for sequences of bytes. -It inherits from ``bytes`` on Python 3 and ``str`` on Python 2. +It inherits from ``bytes``. .. _hy_numeric_models: Numeric Models ~~~~~~~~~~~~~~ -``hy.models.HyInteger`` represents integer literals (using the -``long`` type on Python 2, and ``int`` on Python 3). +``hy.models.HyInteger`` represents integer literals, using the ``int`` +type. ``hy.models.HyFloat`` represents floating-point literals. diff --git a/docs/language/syntax.rst b/docs/language/syntax.rst index 2414499..16ed838 100644 --- a/docs/language/syntax.rst +++ b/docs/language/syntax.rst @@ -10,7 +10,7 @@ An identifier consists of a nonempty sequence of Unicode characters that are not numeric literals ---------------- -In addition to regular numbers, standard notation from Python 3 for non-base 10 +In addition to regular numbers, standard notation from Python for non-base 10 integers is used. ``0x`` for Hex, ``0o`` for Octal, ``0b`` for Binary. .. code-block:: clj @@ -60,13 +60,9 @@ Plain string literals support :ref:`a variety of backslash escapes literally, prefix the string with ``r``, as in ``r"slash\not"``. Bracket strings are always raw strings and don't allow the ``r`` prefix. -Whether running under Python 2 or Python 3, Hy treats all string literals as -sequences of Unicode characters by default, and allows you to prefix a plain -string literal (but not a bracket string) with ``b`` to treat it as a sequence -of bytes. So when running under Python 3, Hy translates ``"foo"`` and -``b"foo"`` to the identical Python code, but when running under Python 2, -``"foo"`` is translated to ``u"foo"`` and ``b"foo"`` is translated to -``"foo"``. +Like Python, Hy treats all string literals as sequences of Unicode characters +by default. You may prefix a plain string literal (but not a bracket string) +with ``b`` to treat it as a sequence of bytes. Unlike Python, Hy only recognizes string prefixes (``r``, etc.) in lowercase. diff --git a/docs/style-guide.rst b/docs/style-guide.rst index 68f2eae..167cad4 100644 --- a/docs/style-guide.rst +++ b/docs/style-guide.rst @@ -39,7 +39,6 @@ into the making of Hy. + Look like a Lisp; DTRT with it (e.g. dashes turn to underscores). + We're still Python. Most of the internals translate 1:1 to Python internals. + Use Unicode everywhere. -+ Fix the bad decisions in Python 2 when we can (see ``true_division``). + When in doubt, defer to Python. + If you're still unsure, defer to Clojure. + If you're even more unsure, defer to Common Lisp. diff --git a/docs/tutorial.rst b/docs/tutorial.rst index 96f8f7f..09cbd52 100644 --- a/docs/tutorial.rst +++ b/docs/tutorial.rst @@ -25,9 +25,6 @@ This is pretty cool because it means Hy is several things: comfort of Python! - For everyone: a pleasant language that has a lot of neat ideas! -Now this tutorial assumes you're running Hy on Python 3. So know things -are a bit different if you're still using Python 2. - Basic intro to Lisp for Pythonistas ===================================