tags:

views:

45

answers:

1

I know this is very evil, but is it possible to add an object to another module's globals, something like:

#module dog.py
import cat
cat.globals.addVar('name','mittens')

and

#module cat.py
print name #mittens
+1  A: 
setattr(cat, 'name', 'mittens')

or

cat.name = 'mittens'
Ignacio Vazquez-Abrams
cat.name should be obvious
FogleBird
@FogleBird: Sure, but not if you don't know that "global scope" is the same as "module scope".
Ignacio Vazquez-Abrams
now that you write it, it seems so obvious I feel a little embarrassed :) but yes, it wasn't clear to me that if you define cat.name then you can access it from inside cat (though in retrospect it's obvious)
noam