«python-descriptors» etiketlenmiş sorular

2
Bir sınıfta tanımlayıcı ayarlamak neden tanımlayıcının üzerine yazıyor?
Basit repro: class VocalDescriptor(object): def __get__(self, obj, objtype): print('__get__, obj={}, objtype={}'.format(obj, objtype)) def __set__(self, obj, val): print('__set__') class B(object): v = VocalDescriptor() B.v # prints "__get__, obj=None, objtype=<class '__main__.B'>" B.v = 3 # does not print "__set__", evidently does not trigger descriptor B.v # does not print anything, we overwrote …
Sitemizi kullandığınızda şunları okuyup anladığınızı kabul etmiş olursunuz: Çerez Politikası ve Gizlilik Politikası.
Licensed under cc by-sa 3.0 with attribution required.