Author Dusty Phillips Reviewers



Download 2,95 Mb.
Pdf ko'rish
bet174/183
Sana20.07.2022
Hajmi2,95 Mb.
#831085
1   ...   170   171   172   173   174   175   176   177   ...   183
Bog'liq
python3-oop

>>> dir(list)
['__add__', '__class__', '__contains__', '__delattr__','__delitem__', 
'__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__
getitem__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', 
'__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__
new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', 
'__rmul__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__
subclasshook__', 'append', 'count', 'extend', 'index', 'insert', 'pop', 
'remove', 'reverse', 'sort'
Further, if we desire additional information on how any of these methods works,
we can use the 
help
function:
>>> help(list.__add__)
Help on wrapper_descriptor:
__add__(self, value, /)
Return self+value.
The plus operator on lists concatenates two lists. We don't have room to discuss all 
of the available special functions in this book, but you are now able to explore all 
this functionality with 
dir
and 
help
. The official online Python reference (
https://
docs.python.org/3/
) has plenty of useful information as well. Focus, especially,  
on the abstract base classes discussed in the 
collections
module.
So, to get back to the earlier point about when we would want to use composition 
versus inheritance: if we need to somehow change any of the methods on the class—
including the special methods—we definitely need to use inheritance. If we used 
composition, we could write methods that do the validation or alterations and ask 
the caller to use those methods, but there is nothing stopping them from accessing 
the property directly. They could insert an item into our list that does not have five 
characters, and that might confuse other methods in the list.
www.it-ebooks.info


Python Data Structures

Download 2,95 Mb.

Do'stlaringiz bilan baham:
1   ...   170   171   172   173   174   175   176   177   ...   183




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish