[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] GLSL in Pygame on a Mac



Brandon N wrote:

Thanks, that seems to be the solution.

Interestingly, perhaps this is a Python feature that I am unaware of but this seems strange to me:

>>> import ctypes
>>> ctypes.util.find_library
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AttributeError: 'module' object has no attribute 'util'
>>> from ctypes.util import find_library
>>>

Is there something unique about the util module in ctypes?

No, this is normal for Python -- you must import a module to use it (not just its package). Pygame actually does a trick with its sub-modules, which is probably what's causing the confusion. For example, you can do

   import pygame
   pygame.display.something(...)

This works because in pygame/__init__.py is something along the lines of:

   import pygame.display

which brings "display" into the module namespace. Most packages I know of don't do this trick -- you must import the packages you want explicitly.

Cheers
Alex.