Update the docs for removing Python 2 support
Some of the example output may still be from Python 2.
This commit is contained in:
parent
081c22d50b
commit
9914e9010c
@ -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))
|
||||
|
@ -564,8 +564,6 @@ requires.
|
||||
File "<input>", line 1, in <module>
|
||||
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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
===================================
|
||||
|
Loading…
Reference in New Issue
Block a user