Scope question
Quinn Dunkan
quinn at upchuck.ugcs.caltech.edu
Tue Feb 12 00:57:49 EST 2002
On 9 Feb 2002 03:36:11 GMT, Philip Swartzleonard <starx at pacbell.net> wrote:
>I may stop doing this in the future though... i think i may make a
>module 'interface' and do 'form xxx import *'s in there, so then import
>it as 'i'. i.wxFrame, i.glutPostRedisplay, etc (it would also be nice if
>there was a sperate module of the GL's that didn't preface GL infront of
>everything. gl.vertex3d looks a lot better than gl.glVertex3d... :)
def un_uGLify(mod_name):
import new
mod = __import__(mod_name)
m = new.module(mod_name)
for k, v in mod.__dict__.items():
if k.startswith('gl'):
k = k[2:]
setattr(m, k, v)
return m
gl = un_uGLify('gl')
... should do what you want... I think.
I don't see what you'd gain from an 'i' module... you'd simply shift all the
potential name clashes and the 'where did this symbol come from'
headscratching over to another module.
More information about the Python-list
mailing list