def?upper_attr(future_class_name,?future_class_parents,?future_class_attr):
????print?'im?in?upper_attr'
????open(r'd:\desktop\123.txt','w').write('nhahahklhfaskjhdf')
????attrs?=?((name,?value)?for?name,?value?in?future_class_attr.items()?if?not?name.startswith('__'))
????uppercase_attr?=?dict((name.upper(),?value)?for?name,?value?in?attrs)
????return?type(future_class_name,?future_class_parents,?uppercase_attr)__metaclass__?=?upper_attrclass?Foo(object):
????bar?=?'bip'print?hasattr(Foo,?'bar')print?hasattr(Foo,?'BAR')f?=?Foo()輸出如下:d:\Desktop\python_example>demo.pyTrueFalsed:\Desktop\python_example>網(wǎng)上的一個例子,首先說,這個例子是有效的。然后題主想調(diào)試一下??纯吹降资侨绾芜\(yùn)行的。請看上文中的這兩句。print?'im?in?upper_attr'open(r'd:\desktop\123.txt','w').write('nhahahklhfaskjhdf')沒響應(yīng)。然后我在這個函數(shù)中設(shè)斷點(diǎn)也進(jìn)不去。
在學(xué)習(xí)python元類的過程中,設(shè)斷點(diǎn)調(diào)試進(jìn)不去,print也沒有輸出,怎么辦?
慕婉清0083722
2018-04-19 15:50:03