NAME and WM

How can I customize the strings WM_NAME and WM_CLASS of a PyQt4 program as shown by xprop ? Consider for example: from PyQt4 import QtGui, QtCore import sys if __name__ == '__main__': app = QtGui.QApplication(sys.argv) app.setStyle("plastique") listView = QtGui.QListView() listView.show() combobox = QtGui.QComboBox() combobox.show() sys.exit(app.exec_(

NAME和WM

我如何自定义xprop所显示的PyQt4程序的字符串WM_NAME和WM_CLASS ? 考虑例如: from PyQt4 import QtGui, QtCore import sys if __name__ == '__main__': app = QtGui.QApplication(sys.argv) app.setStyle("plastique") listView = QtGui.QListView() listView.show() combobox = QtGui.QComboBox() combobox.show() sys.exit(app.exec_()) 如果我通过python xprop_test.py运行

Method overloading decorator

I'm trying to write a decorator that provides method overloading functionality to python, similar to the one mentioned in PEP 3124. The decorator I wrote works great for regular functions, but I can't get it to work for methods in a class. Here is the decorator: class Overload(object): def __init__(self, default): self.default_function = default self.type_map = {}

方法重载装饰器

我正在尝试编写一个装饰器,它为python提供了方法重载功能,类似于PEP 3124中提到的。 我写的装饰器对于常规函数非常有用,但是我无法使它在类中的方法中工作。 这是装饰者: class Overload(object): def __init__(self, default): self.default_function = default self.type_map = {} self.pos = None def __call__(self, *args, **kwargs): print self try:

OpenID server/provider for Django

I am looking for a library to implement on OpenID server in Django. That is, I have my own database of users and need to be my own OpenID provider. I do not need to consume OpenID like all the Django libraries I've found. Are there any good libraries available? The one library I found was https://bitbucket.org/romke/django_openid_provider/, but it hasn't been touched for a year. Is

Django的OpenID服务器/提供程序

我正在寻找一个库在Django的OpenID服务器上实现。 也就是说,我有我自己的用户数据库,需要成为我自己的OpenID提供者。 我不需要像我找到的所有Django库一样使用OpenID。 有没有好的图书馆? 我找到的一个图书馆是https://bitbucket.org/romke/django_openid_provider/,但一年没有被触动。 它状态良好吗? 对于它的价值,我在制作中使用了django_openid_provider(v.0.4),它的表现非常好。 我在这里和那里调整了一些

Identifying the first and last items in a list

I need to transform some text files into HTML code. I'm stuck in transforming a list into an HTML unordered list. Example source: some text in the document * item 1 * item 2 * item 3 some other text The output should be: some text in the document <ul> <li>item 1</li> <li>item 2</li> <li>item 3</li> </ul> some other tex

识别列表中的第一个和最后一个项目

我需要将一些文本文件转换为HTML代码。 我坚持将列表转换为HTML无序列表。 示例源: 文档中的一些文本 *第1项 *第2项 *第3项 一些其他的文字 输出应该是: some text in the document <ul> <li>item 1</li> <li>item 2</li> <li>item 3</li> </ul> some other text 目前,我有这样的: r = re.compile(r'*(.*)n') r.sub('<li>1</li>',

is there any graph digitizer available?

I want to convert a image of a graph (plot) to text data. Is there any existing code to learn from? I had the same problem and ended up writing what I needed from scratch. Here's a link to the python code, and a blog post including a screen shot. You can also use a digitizing software application, to convert graph images to data, that is to numbers. im2graph is free and available for b

有没有图形数字化仪可用?

我想将图形(绘图)的图像转换为文本数据。 有没有现有的代码可以学习? 我遇到了同样的问题,最终从头开始写了我需要的东西。 这里有一个指向python代码的链接,还有一个包含屏幕截图的博客文章。 您还可以使用数字化软件应用程序将图形图像转换为数据,即数字。 im2graph是免费的,可用于Linux和Windows。 见http://www.im2graph.co.il。

SQLAlchemy import tables with relationships

I have problem with separating tables with relationships in different files. I want the tables below to be in three separate files and to import TableA in third party page, but I can not manage the load order. In most of the time I'm receiving the following error. sqlalchemy.exc. InvalidRequestError: When initializing mapper Mapper|TableA|tablea, expression 'TableB' failed to lo

SQLAlchemy使用关系导入表

我有分隔表与不同文件中的关系的问题。 我希望下面的表格位于三个单独的文件中,并在第三方页面中导入TableA ,但我无法管理加载顺序。 在大多数情况下,我收到以下错误。 sqlalchemy.exc。 InvalidRequestError:初始化映射器Mapper | TableA |表时,表达式'TableB'找不到名称(“名称'表B'未定义”)。 如果这是一个类名,考虑在定义了两个相关类之后,将这个关系()添加到类中。 class TableA(Base):

How is the python module search path determined on Mac OS X?

When a non built-in module is imported, the interpreter searches in the locations given by sys.path . sys.path is initialized from these locations (http://docs.python.org/library/sys.html#sys.path): the directory containing the input script (or the current directory) PYTHONPATH the installation-dependent default While the first two sources are straight-forward, can anyone explain how the

在Mac OS X上如何确定python模块的搜索路径?

当一个非内置模块被导入时,解释器将在sys.path给出的位置中进行搜索。 sys.path从这些位置初始化(http://docs.python.org/library/sys.html#sys.path): 包含输入脚本(或当前目录)的目录 PYTHONPATH 依赖于安装的默认值 虽然前两个来源是直截了当的,任何人都可以解释第三个来源是如何工作的,以及影响它的可能性有多大? 虽然我会对一般解决方案感兴趣,但我的具体问题是: 我已经安装了Enthought distributi

python

I am sure many Django developers must come across this issue when using the social-auth. Initially when you develop it, you would like to test it on your local server, hence you would redirect the domainname in your etc/hosts. I came along this in the documentation: https://github.com/omab/django-social-auth#facebook If you define a redirect URL in Facebook setup page, be sure to not defin

蟒蛇

我相信很多Django开发人员在使用社交认证时必须遇到这个问题。 最初当你开发它时,你想在你的本地服务器上测试它,因此你会在你的etc / hosts中重定向域名。 我在文档中提到了这一点: https://github.com/omab/django-social-auth#facebook 如果您在Facebook设置页面中定义重定向URL,请务必不要定义http://localhost:8000因为它在测试时不起作用。 相反,我定义http://myapp.com并在/ etc / hosts上设置映射或使用dnsm

How to have password echoed as asterisks

I am trying to figure out how to prompt for a password, and have the users input echoed back as asterisks ( ******** ) So recently, I took on the project of creating a remote server that could be connected to using the socket module in Python. It's not yet done, as I am in the process of making the console used to connect to the server. I am trying make a login window where a user is pro

如何让密码回显为星号

我想弄清楚如何提示输入密码,并让用户输入回显为星号( ******** ) 所以最近,我开始创建一个可以使用Python中的套接字模块连接到远程服务器的项目。 它还没有完成,因为我正在使控制台用于连接到服务器。 我试图让其中一个用户被提示输入自己的用户名和密码登录窗口,虽然在输入时密码是我期待的星号来打印,如常见的密码输入(即 - Sekr3t被回显为:* * * * * *)。 经过几天的研究,我接近完成,但仍然有最后一个错

cython numpy accumulate function

I need to implement a function for summing the elements of an array with a variable section length. So, a = np.arange(10) section_lengths = np.array([3, 2, 4]) out = accumulate(a, section_lengths) print out array([ 3., 7., 35.]) I attempted an implementation in cython here: https://gist.github.com/2784725 for performance I am comparing to the pure numpy solution for the case where the

cython numpy累积功能

我需要实现一个函数来对可变段长度的数组的元素进行求和。 所以, a = np.arange(10) section_lengths = np.array([3, 2, 4]) out = accumulate(a, section_lengths) print out array([ 3., 7., 35.]) 我尝试在这里使用cython实现: https://gist.github.com/2784725 为了提高性能,我将其与section_lengths全部相同的情况下的纯numpy解决方案进行比较: LEN = 10000 b = np.ones(LEN, dtype=np.int) * 2000 a = np.a