summaryrefslogtreecommitdiffstats
path: root/Demo
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-10-06 08:54:16 (GMT)
committerGeorg Brandl <georg@python.org>2010-10-06 08:54:16 (GMT)
commit57a5e3f0e288b70267297511f5af2c92721d7e2d (patch)
tree7348a8135f76e90360e39b8e9c88b87a591be46d /Demo
parent23b4f927d5e1c55ee0ff26570dfcaf3f307254fe (diff)
downloadcpython-57a5e3f0e288b70267297511f5af2c92721d7e2d.zip
cpython-57a5e3f0e288b70267297511f5af2c92721d7e2d.tar.gz
cpython-57a5e3f0e288b70267297511f5af2c92721d7e2d.tar.bz2
Merged revisions 84249,84264,84326-84327,84407,84476,84480-84482,84484,84530-84531,84553,84619,84684,84915-84916 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k ........ r84249 | georg.brandl | 2010-08-22 01:20:01 +0200 (So, 22 Aug 2010) | 1 line Remove usage of rexec in tkinter demo. ........ r84264 | georg.brandl | 2010-08-22 22:23:38 +0200 (So, 22 Aug 2010) | 1 line #9649: fix default value description. ........ r84326 | georg.brandl | 2010-08-26 16:30:15 +0200 (Do, 26 Aug 2010) | 1 line #9689: add links from overview to in-depth class API descriptions. ........ r84327 | georg.brandl | 2010-08-26 16:30:56 +0200 (Do, 26 Aug 2010) | 1 line #9681: typo. ........ r84407 | georg.brandl | 2010-09-01 23:02:50 +0200 (Mi, 01 Sep 2010) | 1 line #9677: fix link. ........ r84476 | georg.brandl | 2010-09-04 00:14:52 +0200 (Sa, 04 Sep 2010) | 1 line Use tabs consistently. ........ r84480 | georg.brandl | 2010-09-04 00:33:27 +0200 (Sa, 04 Sep 2010) | 1 line More inclusive title. ........ r84481 | georg.brandl | 2010-09-04 00:36:22 +0200 (Sa, 04 Sep 2010) | 1 line #9767: doctest run over json docs. ........ r84482 | georg.brandl | 2010-09-04 00:40:02 +0200 (Sa, 04 Sep 2010) | 1 line #9760: clarify what context expression is. ........ r84484 | georg.brandl | 2010-09-04 00:49:27 +0200 (Sa, 04 Sep 2010) | 1 line Fix missing word. ........ r84530 | georg.brandl | 2010-09-05 19:07:12 +0200 (So, 05 Sep 2010) | 1 line #9747: fix copy-paste error in getresgid() doc. ........ r84531 | georg.brandl | 2010-09-05 19:09:18 +0200 (So, 05 Sep 2010) | 1 line #9776: fix some spacing. ........ r84553 | georg.brandl | 2010-09-06 08:49:07 +0200 (Mo, 06 Sep 2010) | 1 line #9780: both { and } are not valid fill characters. ........ r84619 | georg.brandl | 2010-09-08 12:43:45 +0200 (Mi, 08 Sep 2010) | 1 line Add Lukasz. ........ r84684 | georg.brandl | 2010-09-10 22:43:53 +0200 (Fr, 10 Sep 2010) | 1 line release() is probably not the most important method ........ r84915 | georg.brandl | 2010-09-20 08:27:02 +0200 (Mo, 20 Sep 2010) | 1 line Fix typo. ........ r84916 | georg.brandl | 2010-09-20 08:29:01 +0200 (Mo, 20 Sep 2010) | 1 line Mention % as string formatting. ........
Diffstat (limited to 'Demo')
-rw-r--r--Demo/tkinter/guido/ss1.py29
1 files changed, 13 insertions, 16 deletions
diff --git a/Demo/tkinter/guido/ss1.py b/Demo/tkinter/guido/ss1.py
index 6a7aefc..a6c8c21 100644
--- a/Demo/tkinter/guido/ss1.py
+++ b/Demo/tkinter/guido/ss1.py
@@ -4,7 +4,6 @@ import os
import re
import sys
import cgi
-import rexec
from xml.parsers import expat
LEFT, CENTER, RIGHT = "LEFT", "CENTER", "RIGHT"
@@ -33,16 +32,16 @@ class Sheet:
def __init__(self):
self.cells = {} # {(x, y): cell, ...}
- self.rexec = rexec.RExec()
- m = self.rexec.add_module('__main__')
- m.cell = self.cellvalue
- m.cells = self.multicellvalue
- m.sum = sum
+ self.ns = dict(
+ cell = self.cellvalue,
+ cells = self.multicellvalue,
+ sum = sum,
+ )
def cellvalue(self, x, y):
cell = self.getcell(x, y)
if hasattr(cell, 'recalc'):
- return cell.recalc(self.rexec)
+ return cell.recalc(self.ns)
else:
return cell
@@ -144,7 +143,7 @@ class Sheet:
self.reset()
for cell in self.cells.values():
if hasattr(cell, 'recalc'):
- cell.recalc(self.rexec)
+ cell.recalc(self.ns)
def display(self):
maxx, maxy = self.getsize()
@@ -164,7 +163,7 @@ class Sheet:
if x <= 0 or y <= 0:
continue
if hasattr(cell, 'recalc'):
- cell.recalc(self.rexec)
+ cell.recalc(self.ns)
if hasattr(cell, 'format'):
text, alignment = cell.format()
assert isinstance(text, str)
@@ -317,7 +316,7 @@ class BaseCell:
Subclasses may but needn't provide the following APIs:
cell.reset() -- prepare for recalculation
- cell.recalc(rexec) -> value -- recalculate formula
+ cell.recalc(ns) -> value -- recalculate formula
cell.format() -> (value, alignment) -- return formatted value
cell.xml() -> string -- return XML
"""
@@ -331,7 +330,7 @@ class NumericCell(BaseCell):
self.fmt = fmt
self.alignment = alignment
- def recalc(self, rexec):
+ def recalc(self, ns):
return self.value
def format(self):
@@ -372,7 +371,7 @@ class StringCell(BaseCell):
self.fmt = fmt
self.alignment = alignment
- def recalc(self, rexec):
+ def recalc(self, ns):
return self.text
def format(self):
@@ -398,13 +397,11 @@ class FormulaCell(BaseCell):
def reset(self):
self.value = None
- def recalc(self, rexec):
+ def recalc(self, ns):
if self.value is None:
try:
# A hack to evaluate expressions using true division
- rexec.r_exec("from __future__ import division\n" +
- "__value__ = eval(%s)" % repr(self.translated))
- self.value = rexec.r_eval("__value__")
+ self.value = eval(self.translated, ns)
except:
exc = sys.exc_info()[0]
if hasattr(exc, "__name__"):