python notes

1.python中对目标平台的判断:

import sys
print sys.platform
可能的返回值

This gives you the listaix3 aix4 atheos beos5 darwin freebsd2 freebsd3 freebsd4 freebsd5 freebsd6 freebsd7 generic irix5 irix6 linux2 mac netbsd1 next3 os2emx riscos sunos5 unixware7Of course, sys.platform can have additional values, when Python gets compiled on a system for which no platform-specific directory has been created.

2.调用父类的构造函数

#--------------------------------------------------------------------------------
# test super call
class oldclass:
def __init__(self, *args):
#print "I'm in oldclass, param list is %s" % args
pprint.pprint(args)
pprint.pprint(args[0])
class oldclassderived(oldclass):
def __init__(self, *args):
# call super class's init function
#apply(oldclass.__init__, self, args)
#apply(oldclass.__init__, ((self) + args))
#super(oldclass, self).__init__(args)
#oldclass.__init__(self, args)

apply(oldclass.__init__, ((self, ) + args))

posted on 2012-02-06 13:29  windviki  阅读(227)  评论(0编辑  收藏  举报