[wingide-users] Using import from *

Joshua J. Kugler joshua at eeinternet.com
Fri Mar 19 14:57:14 MDT 2010

On Friday 19 March 2010, Rob Thompson (Vero Software) elucidated thus:
> Hi All,
> This may be a daft question (I'm a newbie) but I am simply trying to
> do this:
> import from ctypes *
> print windll.kernel32
> When I run this as a .py file in WingIDE or using python.exe
> directly, I get:
> NameError: name 'windll' is not defined
> File "d:\Users\Rob Thompson\ctypes.py", line 1, in <module>
>   from ctypes import *
> File "d:\Users\Rob Thompson\ctypes.py", line 2, in <module>
>   print windll.kernel32
> However, if I type the same in by hand into the interpreter I get:
> >>> from ctypes import *
> >>> print windll.kernel32
> <WinDLL 'kernel32', handle 767b0000 at 1c3e230>

I'm going to guess that your script to test ctypes.py is 
named 'ctypes.py'.  Python tries to import from the path containing the 
file doing the import, so is importing your file and not finding what 
it wants.  Rename your test file, and try again. :)


Joshua Kugler
Part-Time System Admin/Programmer
PGP Key: http://pgp.mit.edu/  ID 0x73B13B6A

More information about the wingide-users mailing list