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
1fb071cc
Kaydet (Commit)
1fb071cc
authored
Agu 25, 1997
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Checkpoint.
üst
b2173c31
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
5 deletions
+19
-5
Meta.py
Demo/metaclasses/Meta.py
+19
-5
index.html
Demo/metaclasses/index.html
+0
-0
No files found.
Demo/metaclasses/Meta.py
Dosyayı görüntüle @
1fb071cc
...
...
@@ -29,10 +29,10 @@ class MetaHelper:
raw
=
self
.
__formalclass__
.
__getattr__
(
name
)
except
AttributeError
:
try
:
_getattr_
=
self
.
__dict__
[
'_getattr_'
]
ga
=
self
.
__formalclass__
.
__getattr__
(
'__usergetattr__'
)
except
KeyError
:
raise
AttributeError
,
name
return
_getattr_
(
name
)
return
ga
(
self
,
name
)
if
type
(
raw
)
!=
types
.
FunctionType
:
return
raw
return
self
.
__methodwrapper__
(
raw
,
self
)
...
...
@@ -50,8 +50,13 @@ class MetaClass:
__inited
=
0
def
__init__
(
self
,
name
,
bases
,
dict
):
if
dict
.
has_key
(
'__getattr__'
):
raise
TypeError
,
"Can't override __getattr__; use _getattr_"
try
:
ga
=
dict
[
'__getattr__'
]
except
KeyError
:
pass
else
:
dict
[
'__usergetattr__'
]
=
ga
del
dict
[
'__getattr__'
]
self
.
__name__
=
name
self
.
__bases__
=
bases
self
.
__realdict__
=
dict
...
...
@@ -98,7 +103,16 @@ def _test():
x
=
C
()
print
x
x
.
m1
(
12
)
class
D
(
C
):
def
__getattr__
(
self
,
name
):
if
name
[:
2
]
==
'__'
:
raise
AttributeError
,
name
return
"getattr:
%
s"
%
name
x
=
D
()
print
x
.
foo
print
x
.
_foo
## print x.__foo
## print x.__foo__
if
__name__
==
'__main__'
:
_test
()
...
...
Demo/metaclasses/index.html
0 → 100644
Dosyayı görüntüle @
1fb071cc
This diff is collapsed.
Click to expand it.
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