小编Jon*_*way的帖子

AttributeError:'str'对象没有属性'__module__'

我一直在测试这个缓存方法/代码:http: //code.activestate.com/recipes/498245-lru-and-lfu-cache-decorators/?c = 15348

在某些情况下,我得到这个(或类似的)错误:"AttributeError:'str'对象没有属性' module '"

这里是代码示例,这些工作正常:

if __name__ == '__main__':
@lru_cacheItem(maxsize=20)
def f(x, y):
    return 3*x+y

domain = range(5)
from random import choice
for i in range(1000):
    r = f(choice(domain), choice(domain))

print('Hits:{0}'.format(f.hits), 'Misses:{0}'.format(f.misses))

@lfu_cacheItem(maxsize=20)
def f(x, y):
    return 3*x+y

domain = range(5)
from random import choice
for i in range(1000):
    r = f(choice(domain), choice(domain))

print('Hits:{0}'.format(f.hits), 'Misses:{0}'.format(f.misses))  


@lru_cacheItem(maxsize=20)
def myString(a, b):
    return '{0} and {1}'.format(a, b)

a = 'crap'
b = 'shit'
for i in range(1000):
    r …
Run Code Online (Sandbox Code Playgroud)

python caching

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

如何将.whl转换为.egg?

我想从创建.egg文件.whl。这可能吗?

我发现做相反(答案.whl.egg使用轮包),但我无法弄清楚如何正确地做反向。

python

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

标签 统计

python ×2

caching ×1