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
9d548374
Kaydet (Commit)
9d548374
authored
Nis 13, 2006
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add two entries about how to actually clear a list.
üst
7f573f73
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
5 deletions
+13
-5
tut.tex
Doc/tut/tut.tex
+13
-5
No files found.
Doc/tut/tut.tex
Dosyayı görüntüle @
9d548374
...
...
@@ -1012,7 +1012,7 @@ individual elements of a list:
\end
{
verbatim
}
Assignment to slices is also possible, and this can even change the size
of the list:
of the list
or clear it entirely
:
\begin
{
verbatim
}
>>> # Replace some items:
...
...
@@ -1027,9 +1027,14 @@ of the list:
... a
[
1
:
1
]
=
[
'bletch', 'xyzzy'
]
>>> a
[
123
, 'bletch', 'xyzzy',
1234
]
>>> a
[
:
0
]
=
a # Insert
(
a copy of
)
itself at the beginning
>>> # Insert
(
a copy of
)
itself at the beginning
>>> a
[
:
0
]
=
a
>>> a
[
123
, 'bletch', 'xyzzy',
1234
,
123
, 'bletch', 'xyzzy',
1234
]
>>> # Clear the list: replace all items with an empty list
>>> a
[
:
]
=
[]
>>> a
[]
\end
{
verbatim
}
The built
-
in function
\function
{
len
()
}
also applies to lists:
...
...
@@ -2011,9 +2016,9 @@ applied to complex expressions and nested functions:
There is a way to remove an item from a list given its index instead
of its value: the
\keyword
{
del
}
statement. This differs from the
\method
{
pop
()
}
)
method which returns a value. The
\keyword
{
del
}
statement can also be used to
remove slices from a list
(
which we did earlier by assignment of an
empty list to
the slice
)
. For example:
statement can also be used to
remove slices from a list or clear the
entire list
(
which we did earlier by assignment of an empty list to
the slice
)
. For example:
\begin
{
verbatim
}
>>> a
=
[-
1
,
1
,
66
.
25
,
333
,
333
,
1234
.
5
]
...
...
@@ -2023,6 +2028,9 @@ empty list to the slice). For example:
>>> del a
[
2
:
4
]
>>> a
[
1
,
66
.
25
,
1234
.
5
]
>>> del a
[
:
]
>>> a
[]
\end
{
verbatim
}
\keyword
{
del
}
can also be used to delete entire variables:
...
...
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