[Python-Dev] Pre-PEP: Allow Empty Subscript List Without Parentheses
noamraph at gmail.com
Sun Jun 18 20:02:29 CEST 2006
2006/6/18, Shane Hathaway <shane at hathawaymix.org>:
> Try to think more about how users will use your API. You haven't
> specified where those names (sheet1, income_tax, and profit) are coming
> from. What do you expect users of your library to do to bring those
> names into their namespace?
That's a good question. I'm going to do some bytecode hacks! Something
from spreadsheetlib import SourceCube, CalculatedCube
income_tax = SourceCube()
income_tax = 0.18
years = set([2003, 2004, 2005])
profit = SourceCube([years])
profit = 1000; profit = 2000; profit = 2500
real_profit = CalculatedCube([years], lambda year: profit[year] / (1+
It may be what Talin meant about a "higher level language", but I
don't really change the language - I only inspect the function to see
on what other changeable objects it depends. Those changeable objects
implement some sort of change notification protocol, and it allows the
system to automatically recalculate the result when one of the values
it depends on changes.
(Actually, I intend to change the function to depend directly on the
changeable object instead of look it up every time in the global
namespace, but I don't think that it changes the explanation.)
Note that requiring that all changeable objects will be attributes of
some other object won't remove the need for bytecode hacking: the only
way is to explicitly specify a list of all the objects that the
function depends on, and then give a function that gets these as
arguments. This will really be inconvenient.
But thanks for the suggestion!
More information about the Python-Dev