summaryrefslogtreecommitdiffstats
path: root/FOSS/Python/Dependencies/future-0.18.2/docs/isinstance.rst
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2023-01-23 14:28:53 -0800
committeryum <yum.food.vr@gmail.com>2023-01-23 14:32:09 -0800
commit9fff496394dcd94c4084694ca96a5e07ab836274 (patch)
treed89b78e16ecb6011bdd74555da79f7a8c1d90752 /FOSS/Python/Dependencies/future-0.18.2/docs/isinstance.rst
parent9329d64f991b8b3289af22e4c2eedb09a97c5640 (diff)
package.ps1 now fetches all dependencies
Don't literally check in Python since it looks dodgy (rightfully so). Instead the build script just fetches it. * Update README, simplifying language and documenting other projects
Diffstat (limited to 'FOSS/Python/Dependencies/future-0.18.2/docs/isinstance.rst')
-rw-r--r--FOSS/Python/Dependencies/future-0.18.2/docs/isinstance.rst117
1 files changed, 0 insertions, 117 deletions
diff --git a/FOSS/Python/Dependencies/future-0.18.2/docs/isinstance.rst b/FOSS/Python/Dependencies/future-0.18.2/docs/isinstance.rst
deleted file mode 100644
index 2bb5084..0000000
--- a/FOSS/Python/Dependencies/future-0.18.2/docs/isinstance.rst
+++ /dev/null
@@ -1,117 +0,0 @@
-.. _isinstance-calls:
-
-isinstance
-----------
-
-The following tests all pass on Python 3::
-
- >>> assert isinstance(2**62, int)
- >>> assert isinstance(2**63, int)
- >>> assert isinstance(b'my byte-string', bytes)
- >>> assert isinstance(u'unicode string 1', str)
- >>> assert isinstance('unicode string 2', str)
-
-
-However, two of these normally fail on Python 2::
-
- >>> assert isinstance(2**63, int)
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- AssertionError
-
- >>> assert isinstance(u'my unicode string', str)
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- AssertionError
-
-And if this import is in effect on Python 2::
-
- >>> from __future__ import unicode_literals
-
-then the fifth test fails too::
-
- >>> assert isinstance('unicode string 2', str)
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- AssertionError
-
-
-After importing the builtins from ``future``, all these tests pass on
-Python 2 as on Python 3::
-
- >>> from builtins import bytes, int, str
-
- >>> assert isinstance(10, int)
- >>> assert isinstance(10**100, int)
- >>> assert isinstance(b'my byte-string', bytes)
- >>> assert isinstance(u'unicode string 1', str)
-
-However, note that the last test requires that ``unicode_literals`` be imported to succeed.::
-
- >>> from __future__ import unicode_literals
- >>> assert isinstance('unicode string 2', str)
-
-This works because the backported types ``int``, ``bytes`` and ``str``
-(and others) have metaclasses that override ``__instancecheck__``. See `PEP 3119
-<http://www.python.org/dev/peps/pep-3119/#overloading-isinstance-and-issubclass>`_
-for details.
-
-
-Passing data to/from Python 2 libraries
----------------------------------------
-
-If you are passing any of the backported types (``bytes``, ``int``, ``dict,
-``str``) into brittle library code that performs type-checks using ``type()``,
-rather than ``isinstance()``, or requires that you pass Python 2's native types
-(rather than subclasses) for some other reason, it may be necessary to upcast
-the types from ``future`` to their native superclasses on Py2.
-
-The ``native`` function in ``future.utils`` is provided for this. Here is how
-to use it. (The output showing is from Py2)::
-
- >>> from builtins import int, bytes, str
- >>> from future.utils import native
-
- >>> a = int(10**20) # Py3-like long int
- >>> a
- 100000000000000000000
- >>> type(a)
- future.types.newint.newint
- >>> native(a)
- 100000000000000000000L
- >>> type(native(a))
- long
-
- >>> b = bytes(b'ABC')
- >>> type(b)
- future.types.newbytes.newbytes
- >>> native(b)
- 'ABC'
- >>> type(native(b))
- str
-
- >>> s = str(u'ABC')
- >>> type(s)
- future.types.newstr.newstr
- >>> native(s)
- u'ABC'
- >>> type(native(s))
- unicode
-
-On Py3, the :func:`native` function is a no-op.
-
-
-Native string type
-------------------
-
-Some library code, include standard library code like the ``array.array()``
-constructor, require native strings on Python 2 and Python 3. This means that
-there is no simple way to pass the appropriate string type when the
-``unicode_literals`` import from ``__future__`` is in effect.
-
-The objects ``native_str`` and ``native_bytes`` are available in
-``future.utils`` for this case. These are equivalent to the ``str`` and
-``bytes`` objects in ``__builtin__`` on Python 2 or in ``builtins`` on Python 3.
-
-The functions ``native_str_to_bytes`` and ``bytes_to_native_str`` are also
-available for more explicit conversions.