How to eval some code with in python

Sindh skodela at my-deja.com
Sat Sep 9 15:24:05 EDT 2000


Hi


How do you eval some python code during execution.

eg:

class a:
	segmenta="print 3"
	segmentb='print "ok"'
	segmentc='raise SystemExit'
	... etc

then from python

codec=a()
eval(codec.segmenta)
....

Obviously it isn't working since it says 'syntax error'.

Any idea what I'm doing wrong!

Thanks
Sreekant
--
A man needs to sleep for 36 hours a day atleast.


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list