Re: pre-PEP: Simple Thunks

2005-04-18 Thread Brian Sabbey
Ron_Adam wrote: The load and dump would be private to the data class object. Here's a more complete example. import pickle class PickledData(object): def __init__(self, filename): self.filename = filename self.L = None try:

Re: pre-PEP: Simple Thunks

2005-04-17 Thread Brian Sabbey
Ron_Adam wrote: def pickled_file(thunk, name): f = open(name, 'r') l = pickle.load(f) f.close() thunk(l) f = open(name, 'w') pickle.dump(l, f) f.close() Now I can re-use pickled_file whenever I have to modify a pickled file: do data in pickled

Re: pre-PEP: Simple Thunks

2005-04-17 Thread Brian Sabbey
Bengt Richter wrote: Hm, one thing my syntax does, I just noticed, is allow you to pass several thunks to a thunk-accepter, if desired, e.g., (parenthesizing this time, rather than ending (): with dedented comma) each( ((i): # normal thunk print i), ((j): # alternative

Re: pre-PEP: Suite-Based Keywords

2005-04-17 Thread Brian Sabbey
Brian Sabbey wrote: Does anyone know if the 'where' keyword is only for readability (or does it disambiguate the syntax in some situations)? I think I prefer leaving it off. To answer my own question, I see by reading the where threads that using the 'where' keyword a

Re: pre-PEP: Simple Thunks

2005-04-17 Thread Brian Sabbey
Ron_Adam wrote: On Sat, 16 Apr 2005 17:25:00 -0700, Brian Sabbey Yes, much of what thunks do can also be done by passing a function argument. But thunks are different because they share the surrounding function's namespace (which inner functions do not), and because they can be defined in a

Re: pre-PEP: Suite-Based Keywords

2005-04-17 Thread Brian Sabbey
Oren Tirosh wrote: Take a look at Nick Coglan's "with" proposal: http://groups.google.co.uk/groups?selm=mailman.403.1105274631.22381.python-list%40python.org It addresses many of the same issues (e.g. easy definition of properties). It is more general, though: while your proposal only applies to ke

Re: pre-PEP: Simple Thunks

2005-04-16 Thread Brian Sabbey
Bengt Richter wrote: Good background on thunks can be found in ref. [1]. UIAM most of that pre-dates decorators. What is the relation of thunks to decorators and/or how might they interact? Hmm, I think you answered this below better than I could ;). def f(thunk): before() thunk() after()

Re: pre-PEP: Simple Thunks

2005-04-16 Thread Brian Sabbey
[EMAIL PROTECTED] wrote: Keep in mind that most of the problems come from the "space is significant" thing, which is IMHO a very good idea, but prevents us from putting code in expressions, like : func( a,b, def callback( x ): print x ) or does it ? maybe this s

Re: pre-PEP: Simple Thunks

2005-04-16 Thread Brian Sabbey
On Sat, 16 Apr 2005, Ron_Adam wrote: Thunks are, as far as this PEP is concerned, anonymous functions that blend into their environment. They can be used in ways similar to code blocks in Ruby or Smalltalk. One specific use of thunks is as a way to abstract acquire/release code. Another use is as a

Re: pre-PEP: Simple Thunks

2005-04-16 Thread Brian Sabbey
Leif K-Brooks wrote: Brian Sabbey wrote: Thunk statements contain a new keyword, 'do', as in the example below. The body of the thunk is the suite in the 'do' statement; it gets passed to the function appearing next to 'do'. The thunk gets inserted as the f

Re: pre-PEP: Suite-Based Keywords

2005-04-16 Thread Brian Sabbey
005 04:45 pm, Brian Sabbey wrote: Here is a pre-PEP for what I call "suite-based keyword arguments". The mechanism described here is intended to act as a complement to thunks. Please let me know what you think. Kind of cool. If we had full lambdas aka as anonymous defs (def foo(...) wi

Re: pre-PEP: Suite-Based Keywords

2005-04-16 Thread Brian Sabbey
Reinhold Birkenfeld wrote: Brian Sabbey wrote: Here is a pre-PEP for what I call "suite-based keyword arguments". The mechanism described here is intended to act as a complement to thunks. Please let me know what you think. Suite-Based Keyword Arguments ---

Re: pre-PEP: Suite-Based Keywords

2005-04-16 Thread Brian Sabbey
Shane Hathaway wrote: Kent Johnson wrote: Brian Sabbey wrote: Using suite-based keyword arguments, the code f(x = 1) is equivalent to f(): x = 1 ISTM the syntax is ambiguous. How do you interpret if f(): x = 1 ? Is a suite alllowed only when a block could not be introduced in the current

pre-PEP: Suite-Based Keywords

2005-04-15 Thread Brian Sabbey
Here is a pre-PEP for what I call "suite-based keyword arguments". The mechanism described here is intended to act as a complement to thunks. Please let me know what you think. Suite-Based Keyword Arguments - Passing complicated arguments to functions is currently awk

pre-PEP: Simple Thunks

2005-04-15 Thread Brian Sabbey
Here is a first draft of a PEP for thunks. Please let me know what you think. If there is a positive response, I will create a real PEP. I made a patch that implements thunks as described here. It is available at: http://staff.washington.edu/sabbey/py_do Good background on thunks can be fo