James Lu wrote:
as expr [do comma-separated-expressions]:
>block
means evaluate expr, then call the result of the expression. If do is
present, call it with the argument list after do.
This kind of thing has been proposed before. Although it seems
like a straightforward idea, there are s
Hi James
This is an attempt to respond to the issues that be lying behind your
request for code blocks in Python. It's my two cents worth
(https://en.wikipedia.org/wiki/My_two_cents) of opinion.
I really do wish we could have language that had all of Ruby's
strengths, and also all of Python's. Th
By passing a function to another function I meant passing a code block as an
inline function to a function call.
The do statement is simply the arguments the function is called with
Brackets = optional
as expr [do comma-separated-expressions]:
block
means evaluate expr, then call the result
I *think* you are trying to find a syntax for "code blocks" like Ruby
has, but I'm not sure. Your examples are a little confusing to me
(possibly because you have at least three separate suggestions here,
"as" blocks, a mysterious "do" keyword I don't understand, and partial
application using %
On Thu, Jul 26, 2018 at 02:07:07PM +0200, Michel Desmoulin wrote:
> 4 - introducing a new keyword is the hardest thing you can ever ask on
> this list.
Introducing a new keyword is like falling off a log compared to
introducing a new operator.
--
Steve
_
> lumberjack(15, %)
> # is equivalent to the expression
> lambda x: lumberjack(15, %)
You mean lambda x: lumberjack(15, x) ?
So you'd want a better syntax for functools.partial, here your example is
partial(lumberjack, 15).
However this syntax you allow to write lumberjack(%, 15) which is only
p
I like the concept, and I several times wished I could have had a
reference to the block of code in a `with` clause.
However, it is unlikely to happen:
1 - Guido restricted lambda to one expression, and this would just be a
way around that
2 - This will be tempting to use for callbacks and chain
On 25/07/18 18:07, James Lu wrote:
I'm open to any changes or criticism.
```
import atexit
as atexit.register:
# ...do various cleanup tasks...
print('Goodbye')
# is approximately equivalent to =>
import atexit
def _():
# ...do various cleanup tasks...
print('Goodbye')
atexi
I'm open to any changes or criticism.
```
import atexit
as atexit.register:
# ...do various cleanup tasks...
print('Goodbye')
# is approximately equivalent to =>
import atexit
def _():
# ...do various cleanup tasks...
print('Goodbye')
atexit.register(_)
# flask example
@app.route