Creating "virtual" module-namespace

Simon simon.12.ghum at spamgourmet.com
Wed Dec 11 17:17:43 EST 2002


Imagine... there is a:

a= "class nasenbaer:\n  def singt():\n    print "tralala"\n\n"

(the content of a is:
class nasenbaer:
    	def singt():
    	    	print "tralala"


)

now I want to exec a in a "special" way so that later I can call

exec a in ???????

grail=somthing.nasenbaer()
grail.singt()

My try was 

b=globals()

exec a in b
grail=b.nasenbaer()

but it failed...

what is the correct way?



More information about the Python-list mailing list