A critic of Guido's blog on Python's lambda
NOatkinwSPAM at rpi.edu
Sun May 7 09:02:17 CEST 2006
"Serge Orlov" <Serge.Orlov at gmail.com> writes:
> Ken Tilton wrote:
>> It is vastly more disappointing that an alleged tech genius would sniff
>> at the chance to take undeserved credit for PyCells, something probably
>> better than a similar project on which Adobe (your superiors at
>> software, right?) has bet the ranch. This is the Grail, dude, Brooks's
>> long lost Silver Bullet. And you want to pass?????
>> C'mon, Alex, I just want you as co-mentor for your star quality. Of
>> course you won't have to do a thing, just identify for me a True Python
>> Geek and she and I will take it from there.
>> Here's the link in case you lost it:
>> peace, kenny
>> ps. flaming aside, PyCells really would be amazingly good for Python.
>> And so Google. (Now your job is on the line. <g>) k
> Perhaps I'm missing something but what's the big deal about PyCells?
> Here is 22-lines barebones implementation of spreadsheet in Python,
> later I create 2 cells "a" and "b", "b" depends on a and evaluate all
> the cells. The output is
> a = negate(sin(pi/2)+one) = -2.0
> b = negate(a)*10 = 20.0
> =================== spreadsheet.py ==================
> class Spreadsheet(dict):
> def __init__(self, **kwd):
> self.namespace = kwd
> def __getitem__(self, cell_name):
> item = self.namespace[cell_name]
> if hasattr(item, "formula"):
> return item()
> return item
> def evaluate(self, formula):
> return eval(formula, self)
> def cell(self, cell_name, formula):
> "Create a cell defined by formula"
> def evaluate_cell():
> return self.evaluate(formula)
> evaluate_cell.formula = formula
> self.namespace[cell_name] = evaluate_cell
> def cells(self):
> "Yield all cells of the spreadsheet along with current values
> and formulas"
> for cell_name, value in self.namespace.items():
> if not hasattr(value, "formula"):
> yield cell_name, self[cell_name], value.formula
> import math
> def negate(x):
> return -x
> sheet1 = Spreadsheet(one=1, sin=math.sin, pi=math.pi, negate=negate)
> sheet1.cell("a", "negate(sin(pi/2)+one)")
> sheet1.cell("b", "negate(a)*10")
> for name, value, formula in sheet1.cells():
> print name, "=", formula, "=", value
I hope Ken doesn't mind me answering for him, but Cells is not a
spreadsheet (where did you get that idea?). It does apply the basic
idea of a spreadsheet to software - that is, instead of updating value
when some event occurs, you specify in advance how that value can be
computed and then you stop worrying about keeping it updated.
Incidentally, is this supposed to be an example of Python's supposed
"aesthetic pleasantness"? I find it a little hideous, even giving you
the benefit of the doubt and pretending there are newlines between
each function. There's nothing like a word wrapped in pairs of
underscores to totally ruin an aesthetic experience.
P.S. Is this really a spreadsheet? It looks like it's a flat
This is a song that took me ten years to live and two years to write.
- Bob Dylan
More information about the Python-list