小编qMa*_*Max的帖子

为什么__getitem__不能成为classmethod?

假设以下课程:

class Class(object):
    @classmethod
    def getitem(*args):
        print 'getitem %s' % (args,)
    @classmethod
    def __getitem__(*args):
        print '__getitem__ %s' % (args,)
Run Code Online (Sandbox Code Playgroud)

getitem方法的行为符合预期:它Class作为第一个arg __getitem__接收,但type作为第一个arg 接收:

calling Class.getitem(test)
getitem (<class '__main__.Class'>, 'test')

calling obj.getitem(test)
getitem (<class '__main__.Class'>, 'test')

calling Class[test]
'type' object has no attribute '__getitem__'

calling obj[test]
__getitem__ (<class '__main__.Class'>, 'test')
Run Code Online (Sandbox Code Playgroud)

背后有什么魔力__getitem__

python class-method

15
推荐指数
2
解决办法
4313
查看次数

使用emacs CEDET完成python

在cedet-1.0的默认安装中,完成只能跟踪当前文件中的全局范围符号.这与内置完成功能(dabbrev-expand或hippie-expand)没有多大区别.

它既可以从导入的模块也不从类属性中完成符号.不是说它无法处理'自我'.

是否有可能调整语义来做事情?

PS ECB代码浏览器可以看到所有import/base classess和东西.符号完成工作不正确或未正确设置.

python emacs code-completion cedet

10
推荐指数
1
解决办法
2777
查看次数

iframe / popup中的Google oauth2授权

我的应用程序可在iframe中运行(注入chrome扩展名)。该应用程序需要向用户询问有关Google oauth2的权限。由于存在X-Frame-Options:SAMEORIGIN,网址https://accounts.google.com/o/oauth2/auth,因此重定向到oauth-page不能直接在iframe中使用

有没有办法在弹出窗口中显示页面?

x-frame-options oauth-2.0

5
推荐指数
1
解决办法
3177
查看次数

绝对定位嵌套元素上的 z-index

我有一些绝对定位的盒子。其中之一具有嵌套弹出窗口,大于框。我想在所有盒子前面弹出。

z-index: 100在框和z-index: 200弹出窗口上设置无济于事。在带有弹出框的框之后按文档顺序排列的框似乎超过了弹出框。我想念 z 索引的什么?

div {
    border: 1px solid black;
}

.container {
    position: relative;
}

.foo {
    position: absolute;
    background-color: white;
    width: 5em;
    z-index: 100;
}

#b0 {
    top: 0em;
    left: 0em;
}

#b1 {
    top: 3em;
    left: 1em;
}

#b2 {
    top: 6em;
    left: 2em;
}

#b3 {
    top: 9em;
    left: 3em;
}

#b4 {
    top: 12em;
    left: 4em;
}

.popup {
    z-index: 200;
    position: absolute;
    left: 1em;
    top: -1em;
    width: 8em;
    height: …
Run Code Online (Sandbox Code Playgroud)

html css z-index css-position

4
推荐指数
1
解决办法
6284
查看次数