Pelokalan
Python ID
id en
Masuk
Proyek
builtins__stdtypes.po Berkas proyek · python-docs-id-3.14 · Bahasa Indonesia
Modul PO Hanya lihat
Teks sumber — English
Terjemahan — Bahasa Indonesia
Operations and built-in functions that have a Boolean result always return ``0`` or ``False`` for false and ``1`` or ``True`` for true, unless otherwise stated. (Important exception: the Boolean operations ``or`` and ``and`` always return one of their operands.)
Operasi dan fungsi bawaan yang memiliki hasil *Boolean* selalu mengembalikan ``0`` atau ``False`` untuk yang bernilai salah dan ``1`` atau ``True`` untuk yang bernilai benar, kecuali dinyatakan lain. (Pengecualian penting: operasi *Boolean* ``or`` dan ``and`` selalu mengembalikan salah satu operan mereka.)
Numbers are created by numeric literals or as the result of built-in functions and operators. Unadorned integer literals (including hex, octal and binary numbers) yield integers. Numeric literals containing a decimal point or an exponent sign yield floating-point numbers. Appending ``'j'`` or ``'J'`` to a numeric literal yields an imaginary number (a complex number with a zero real part) which you can add to an integer or float to get a complex number with real and imaginary parts.
Conversion from :class:`float` to :class:`int` truncates, discarding the fractional part. See functions :func:`math.floor` and :func:`math.ceil` for alternative conversions.
Python's :term:`generators <generator>` -- or more precisely, :term:`generator functions <generator function>` and :term:`generator iterators <generator iterator>` -- provide a convenient way to implement the iterator protocol.
Generator functions behave as regular :ref:`user-defined functions <user-defined-funcs>` (for example, they have the same attributes), except that calling a generator function returns a :ref:`generator iterator <generator-methods>`::
One common use for generator functions is implementing the :meth:`~object.__iter__` method of custom iterable objects. For example::
The builtin functions :func:`isinstance` and :func:`issubclass` do not accept ``GenericAlias`` types for their second argument::
Functions
Fungsi-Fungsi
There are really two flavors of function objects: built-in functions and user-defined functions. Both support the same operation (to call the function), but the implementation is different, hence the different object types.
Methods are functions that are called using the attribute notation. There are two flavors: :ref:`built-in methods <builtin-methods>` (such as :meth:`~list.append` on lists) and :ref:`class instance methods <instance-methods>`. Built-in methods are described with the types that support them.
A code object can be executed or evaluated by passing it (instead of a source string) to the :func:`exec` or :func:`eval` built-in functions.
This object is returned by functions that don't explicitly return a value. It supports no special operations. There is exactly one null object, named ``None`` (a built-in name). ``type(None)()`` produces the same singleton.
The :ref:`type parameters <type-params>` of generic classes, functions, and :ref:`type aliases <type-aliases>`. For classes and functions that are not generic, this will be an empty tuple.
The limitations do not apply to functions with a linear algorithm: