Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
293dd4b7
Kaydet (Commit)
293dd4b7
authored
Haz 04, 2002
tarafından
Fred Drake
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix up Guido's markup.
üst
16c8d702
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
24 deletions
+24
-24
ref3.tex
Doc/ref/ref3.tex
+24
-24
No files found.
Doc/ref/ref3.tex
Dosyayı görüntüle @
293dd4b7
...
...
@@ -12,7 +12,7 @@ program is represented by objects or by relations between objects.
Every object has an identity, a type and a value. An object's
\emph
{
identity
}
never changes once it has been created; you may think
of it as the object's address in memory. The `
\
code
{
is
}
' operator
of it as the object's address in memory. The `
\
keyword
{
is
}
' operator
compares the identity of two objects; the
\function
{
id()
}
\bifuncindex
{
id
}
function returns an integer
representing its identity (currently implemented as its address).
...
...
@@ -1540,10 +1540,10 @@ original arguments to the operation.
\item
New-style classes (those derived from
\c
ode
{
object
}
) never invoke the
\
code
{__
coerce
__
}
method in response to a binary operator; the only
time
\
code
{__
coerce
__
}
is invoked is when the built-in function
\
code
{
coerce()
}
is called.
New-style classes (those derived from
\c
lass
{
object
}
) never invoke the
\
method
{__
coerce
__
()
}
method in response to a binary operator; the only
time
\
method
{__
coerce
__
()
}
is invoked is when the built-in function
\
function
{
coerce()
}
is called.
\item
...
...
@@ -1565,7 +1565,7 @@ binary operator, and \method{__iadd__} for the in-place variant.
For objects
\var
{
x
}
and
\var
{
y
}
, first
\code
{
\var
{
x
}
.
__
op
__
(
\var
{
y
}
)
}
is tried. If this is not implemented or returns
\code
{
NotImplemented
}
,
\code
{
\var
{
y
}
.
__
rop
__
(
\var
{
x
}
)
}
is tried. If this is also not
implemented or returns
\code
{
NotImplemented
}
, a
\
code
{
TypeError
}
implemented or returns
\code
{
NotImplemented
}
, a
\
exception
{
TypeError
}
exception is raised. But see the following exception:
\item
...
...
@@ -1573,8 +1573,8 @@ exception is raised. But see the following exception:
Exception to the previous item: if the left operand is an instance of
a built-in type or a new-style class, and the right operand is an
instance of a proper subclass of that type or class, the right
operand's
\
code
{__
rop
__
}
method is tried
\emph
{
before
}
the left
operand's
\
code
{__
op
__
}
method. This is done so that a subclass can
operand's
\
method
{__
rop
__
()
}
method is tried
\emph
{
before
}
the left
operand's
\
method
{__
op
__
()
}
method. This is done so that a subclass can
completely override binary operators. Otherwise, the left operand's
__
op
__
method would always accept the right operand: when an instance
of a given class is expected, an instance of a subclass of that class
...
...
@@ -1583,17 +1583,17 @@ is always acceptable.
\item
When either operand type defines a coercion, this coercion is called
before that type's
\
code
{__
op
__}
or
\code
{__
rop
__}
method is called,
but no sooner. If the coercion returns an object of a different type
for the operand whose coercion is invoked, part of the process is
redone using the new object.
before that type's
\
method
{__
op
__
()
}
or
\method
{__
rop
__
()
}
method is
called, but no sooner. If the coercion returns an object of a
different type for the operand whose coercion is invoked, part of the
process is
redone using the new object.
\item
When an in-place operator (like `
\code
{
+=
}
') is used, if the left
operand implements
\
code
{__
iop
__}
, it is invoked without any coercion.
When the operation falls back to
\code
{__
op
__}
and/or
\code
{__
rop
__}
,
the normal coercion rules apply.
operand implements
\
method
{__
iop
__
()
}
, it is invoked without any
coercion. When the operation falls back to
\method
{__
op
__
()
}
and/or
\method
{__
rop
__
()
}
,
the normal coercion rules apply.
\item
...
...
@@ -1604,23 +1604,23 @@ sequence concatenation, sequence concatenation is invoked.
In
\var
{
x
}
\code
{
*
}
\var
{
y
}
, if one operator is a sequence that
implements sequence repetition, and the other is an integer
(
\c
ode
{
int
}
or
\code
{
long
}
), sequence repetition is invoked.
(
\c
lass
{
int
}
or
\class
{
long
}
), sequence repetition is invoked.
\item
Rich comparisons (implemented by methods
\
code
{__
eq
__
}
and so on)
Rich comparisons (implemented by methods
\
method
{__
eq
__
()
}
and so on)
never use coercion. Three-way comparison (implemented by
\
code
{__
cmp
__
}
) does use coercion under the same conditions as
\
method
{__
cmp
__
()
}
) does use coercion under the same conditions as
other binary operations use it.
\item
In the current implementation, the built-in numeric types
\c
ode
{
int
}
,
\c
ode
{
long
}
and
\code
{
float
}
do not use coercion; the type
\c
ode
{
complex
}
however does use it. The difference can become
In the current implementation, the built-in numeric types
\c
lass
{
int
}
,
\c
lass
{
long
}
and
\class
{
float
}
do not use coercion; the type
\c
lass
{
complex
}
however does use it. The difference can become
apparent when subclassing these types. Over time, the type
\c
ode
{
complex
}
may be fixed to avoid coercion. All these types
implement a
\
code
{__
coerce
__
}
method, for use by the built-in
\
code
{
coerce
}
function.
\c
lass
{
complex
}
may be fixed to avoid coercion. All these types
implement a
\
method
{__
coerce
__
()
}
method, for use by the built-in
\
function
{
coerce()
}
function.
\end{itemize}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment