直接引用 Python 的标准库 [英] Directly Reference Python's Standard Library

查看:64
本文介绍了直接引用 Python 的标准库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以事实证明 PyQt 重新定义了一个函数 hex(),不幸的是,这导致 Python 标准库 hex() 无法使用.我正在处理一个大型软件项目,并且已使用 *imports 进行设置:

So it turns out that PyQt redefines a function hex(), which unfortunately renders the python standard library hex() unusable. I'm working on a large software project and it's been set up with *imports:

from PyQt4.QtCore import *
from PyQt4.QtGui import *

...等

我需要标准的python hex() 函数,有什么方法可以参考它吗?我在考虑 stdlib.hex() 或类似的东西?

I need the standard python hex() function, is there any way for me to reference it? I'm thinking of a stdlib.hex() or something like that?

目前我丑陋的解决方法是:

Currently my ugly workaround is:

pyHex = hex
from PyQt4.QtCore import *
from PyQt4.QtGui import *
hex = pyHex

而且我真的不想这样做.

and I'd really prefer to not have to do that.

谢谢.

推荐答案

from __builtin__ import hex

使用__builtin__模块.

这篇关于直接引用 Python 的标准库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆