[PyQt] Strange shadowing of hex() function by PyQt4.QtCore

Boris Barbour barbour at ens.fr
Fri Aug 8 02:33:57 BST 2008


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

ipython transcript illustrating the problem (I'm running on an up-to-date 
debian testing on linux):

-------
Python 2.5.2 (r252:60911, May 28 2008, 19:19:25)
Type "copyright", "credits" or "license" for more information.

IPython 0.8.4 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object'. ?object also works, ?? prints more.

  Welcome to pylab, a matplotlib-based Python environment.
  For more information, type 'help(pylab)'.

In [1]: ?hex
Type:           builtin_function_or_method
Base Class:     <type 'builtin_function_or_method'>
String Form:    <built-in function hex>
Namespace:      Python builtin
Docstring:
    hex(number) -> string

    Return the hexadecimal representation of an integer or long integer.


In [2]: hex(65)
Out[2]: '0x41'

In [3]: from PyQt4.QtCore import *

In [4]: hex(65)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/home/boris/development/pynaptix/<ipython console> in <module>()

TypeError: argument 1 of hex() has an invalid type

In [5]: ?hex
Type:           builtin_function_or_method
Base Class:     <type 'builtin_function_or_method'>
String Form:    <built-in function hex>
Namespace:      Interactive
Docstring:
    <no docstring>



More information about the PyQt mailing list