Directly Reference Python's Standard Library

北战南征 提交于 2019-12-12 17:37:16

问题


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 *

...etc

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.

Thanks.


回答1:


from __builtin__ import hex

Use the __builtin__ module.



来源:https://stackoverflow.com/questions/24562216/directly-reference-pythons-standard-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!