2009-03-15 06:51:39 +00:00
|
|
|
import urllib
|
|
|
|
import re
|
|
|
|
|
|
|
|
re_lineends = re.compile(r'[\r\n]*')
|
|
|
|
|
|
|
|
#command
|
2009-03-15 07:25:32 +00:00
|
|
|
def py(input):
|
2009-03-15 06:51:39 +00:00
|
|
|
res = urllib.urlopen("http://eval.appspot.com/eval?statement=%s" %
|
2009-03-15 07:25:32 +00:00
|
|
|
urllib.quote(input.strip(),safe='')).readlines()
|
2009-03-15 06:51:39 +00:00
|
|
|
if len(res) == 0:
|
|
|
|
return
|
|
|
|
res[0] = re_lineends.split(res[0])[0]
|
|
|
|
if not res[0] == 'Traceback (most recent call last):':
|
|
|
|
return res[0]
|
|
|
|
else:
|
|
|
|
return res[-1]
|