google又被封,实在太不可爱了
动不动就这样,连mail都看不了了,代理代理,这样实在是太不可爱了,sigh。
刚才在python邮件列表中看到有人提出这样的一个问题:
I am writing a library in which I need to find the names of methods
which are implemented in a class, rather than inherited from another
class. To explain more, and to find if there is another way of doing
it, here is what I want to do: I am defining two classes, say A and B,
as:
class A(object):
def list_cmds(self):
’implementation needed’
?
def __init__(self):
… (rest of class)
class B(A):
def cmd1(self, args):
pass
def cmd2(self, args):
pass
I need an implementation of list_cmds in A above so that I can get a
result:
>>> b=B()
>>> b.list_cmds()
['cmd1','cmd2'] #order not important
I will be happy if anybody can point to me any way of doing it, using
class attributes, metaclasses or otherwise. What I don’t want to do is
modifying class B, which contains just the cmds, if possible.
想了一下我使用下面的代码完成了他所需要的功能:
#!/usr/bin/python #filename: p.y class A(object): def listcmds(self): allInChild = dir(self) allInParent = dir(A) allOnlyInChild = [] for att in allInChild: if att not in allInParent: allOnlyInChild.append(att) return allOnlyInChild def __init__(self): pass class B(A): def m1(self): pass def m2(self): pass b = B() print b.listcmds()
昨天参考了网上一份升级gnome到2.14的文档,把gnome从2.14升级到了2.16,方法也很简单,我写的比较简略,需要更详细的介绍和解释,可以参考原文档(http://gentoo-wiki.com/HOWTO_Update_to_GNOME_unstable):
gnome2.16 9月6号才进入portgae吧,首先要更新一下portage:
emerge --sync
sed -n '/# New GNOME 2.16 gtk# components/,/# End GNOME 2.16 mask/p' /usr/portage/profiles/package.mask >> /etc/portage/package.unmask
sed -n '/# New GNOME 2.16 gtk# components/,/# End GNOME 2.16 mask/p' /usr/portage/profiles/package.mask |awk '{ print $1 " ~x86" }' >> /etc/portage/package.keywords
ACCEPT_KEYWORDS="~x86" emerge -p =gnome-base/gnome-2.16* | grep \[ebuild |awk '{ print $4 }' | sed -e 's/^/~/' -e 's/-r[0-9]{1,2}//' |uniq -u | sort >>/etc/portage/package.keywords
emerge -DuN gnome
gentoo发布了2006.1,系统有很久没有更新过了,借此机会更新到2006.1吧。
因为这是一个新的release,先更改系统的profile:
rm /etc/make.profile
ln -s /usr/protage/profiles/default-linux/x86/2006.1 /etc/make.profile
接下来下载需要更新的软件包:
emerge -feuDv system
emerge -feuDv world
更新system:
emerge -euDv system
emerge -euDv world
这又是一个漫长的过程,估计明天要工作一整天了。
没有网络的确很不方便,生活不能没有网络。