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
ff564d33
Kaydet (Commit)
ff564d33
authored
Mar 08, 2005
tarafından
Greg Ward
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
SF #1156412: document the __new__() static method
(merge from release24-maint branch).
üst
50682d0f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
0 deletions
+29
-0
ref3.tex
Doc/ref/ref3.tex
+29
-0
No files found.
Doc/ref/ref3.tex
Dosyayı görüntüle @
ff564d33
...
@@ -1052,6 +1052,35 @@ extracting a slice may not make sense. (One example of this is the
...
@@ -1052,6 +1052,35 @@ extracting a slice may not make sense. (One example of this is the
\subsection
{
Basic customization
\label
{
customization
}}
\subsection
{
Basic customization
\label
{
customization
}}
\begin{methoddesc}
[object]
{__
new
__}{
cls
\optional
{
,
\moreargs
}}
Called to create a new instance of class
\var
{
cls
}
.
\method
{__
new
__
()
}
is a static method (special-cased so you need not declare it as such)
that takes the class of which an instance was requested as its first
argument. The remaining arguments are those passed to the object
constructor expression (the call to the class). The return value of
\method
{__
new
__
()
}
should be the new object instance (usually an
instance of
\var
{
cls
}
).
Typical implementations create a new instance of the class by invoking
the superclass's
\method
{__
new
__
()
}
method using
\samp
{
super(
\var
{
currentclass
}
,
\var
{
cls
}
).
__
new
__
(
\var
{
cls
}
[, ...])
}
with appropriate arguments and then modifying the newly-created instance
as necessary before returning it.
If
\method
{__
new
__
()
}
returns an instance of
\var
{
cls
}
, then the new
instance's
\method
{__
init
__
()
}
method will be invoked like
\samp
{__
init
__
(
\var
{
self
}
[, ...])
}
, where
\var
{
self
}
is the new instance
and the remaining arguments are the same as were passed to
\method
{__
new
__
()
}
.
If
\method
{__
new
__
()
}
does not return an instance of
\var
{
cls
}
, then the
new instance's
\method
{__
init
__
()
}
method will not be invoked.
\method
{__
new
__
()
}
is intended mainly to allow subclasses of
immutable types (like int, str, or tuple) to customize instance
creation.
\end{methoddesc}
\begin{methoddesc}
[object]
{__
init
__}{
self
\optional
{
,
\moreargs
}}
\begin{methoddesc}
[object]
{__
init
__}{
self
\optional
{
,
\moreargs
}}
Called
\indexii
{
class
}{
constructor
}
when the instance is created. The
Called
\indexii
{
class
}{
constructor
}
when the instance is created. The
arguments are those passed to the class constructor expression. If a
arguments are those passed to the class constructor expression. If a
...
...
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