Questions #1



Download 85,32 Kb.
bet9/24
Sana06.07.2022
Hajmi85,32 Kb.
#752107
1   ...   5   6   7   8   9   10   11   12   ...   24
Bog'liq
interview en

for key in { 'foo' : 1 , 'bar' : 2 }:
process_key(key)

How to iterate a dictionary over key-value pairs?
The .iteritems() dictionary method returns a (key, value) tuple generator.

Classes, objects


How to get a list of object attributes?
The dir function returns a list of strings - fields of the object. The __dict__ field contains a dictionary of the form {field -> value}.
What are magical methods, what are they for?
Magic methods are methods whose names begin and end with a double underscore. They are magical because they are almost never called explicitly. They are called by built-in functions or syntactic constructs. For example, the len() function calls the __len__() method of the passed object. The __add__(self, other) method is called automatically when added with the + operator.
Here are some magical methods:

How can I refer to the parent class in a class?
The super function takes a class and an instance:
class NextClass (FirstClass):
def __init__ ( self , x):
super (NextClass, self ).__init__()
self .x = x

Is multiple inheritance possible? What is MRO?
Yes, you can specify more than one parent in a child class.
MRO - method resolution order, method resolution order. The algorithm by which the method should be searched if the class has two or more parents. The algorithm linearizes the inheritance graph. Briefly, it can be described as follows: search from left to right. Therefore, the more to the right a class is, the less priority it has when searching for a method.

Download 85,32 Kb.

Do'stlaringiz bilan baham:
1   ...   5   6   7   8   9   10   11   12   ...   24




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