On Fri, Aug 8, 2008 at 10:02, Mark Summerfield <[EMAIL PROTECTED]> wrote: > On 2008-08-08, Boris Barbour wrote: >> Hi, >> >> Importing PyQt4.QtCore seems to alter or shadow the builtin hex() >> function. I'm afraid I haven't tracked things down further - I just >> learnt the hard way to "import" instead of "from import *". However, >> I'm not sure the clash is intended, so I'm reporting it. >> >> Best regards, >> >> Boris > [snip] > > It is unfortunate that doing * imports on PyQt4 brings in some objects > which don't begin with q or Q. Here's a solution for hex shown as an > IDLE session: > > >>> hex(123) > '0x7b' > >>> from PyQt4.QtCore import * > >>> hex(123) > > Traceback (most recent call last): > File "<pyshell#3>", line 1, in <module> > hex(123) > TypeError: argument 1 of hex() has an invalid type > >>> __builtins__.hex(123) > '0x7b' > >>> # restore built-in hex > >>> hex = __builtins__.hex > >>> hex(123) > '0x7b'
This also bite me many times when I was doing a fast hack using from PyQt4.QtCore import *. Shadowing stdlib functions is evil. Regards, ismail -- Programmer Excuse #11: I figured I didn't need to test because it was obviously correct. _______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt