碰到的python问题经验总结

1.从不同位置import进来的类会导致isinstance失败

##################################
#bug.py
class Foo:
    pass
import module3

print(isinstance(Foo(), bug.Foo))
#输出True,False
###################################
2.默认list参数可能在定义时已经初始化好了,多次调用使用的是同一个对象
###################################
def sayhi(msg=[]):
    msg.append("hi")
    print len(msg)
sayhi()
sayhi()
#输出1,2
###################################

用python杀进程 activestat.com --- Recipe 347462
Recipe 305279: getting process information on windows (Python)
Recipe 303339: getting process information on windows (Python)

打出异常堆栈
"".join(traceback.format_exception(*sys.exc_info()))
"".join(traceback.format_exc())
打出堆栈
traceback.print_stack(sys._getframe(1))
打出被谁调用
print  sys._getframe(1).f_code.co_name
获得版本的magic number,
imp.get_magic()

你可能感兴趣的:(windows,python,F#)