Travis Parks writes:
> I also like partial function application. What is the easiest way of
> achieving this in Python? Would it look something like this:
>
> def foo(x, y):
> return x + y
>
> xFoo = lambda y: foo(10, y)
from functools import partial
xfoo = partial(foo, 10)
--
Piet van Oost
On 8/31/2011 12:45 PM, Travis Parks wrote:
I was a little disappointed the other day when I realized that
closures were read-only.
'Were', in 2.x. The standard 2.x workaround for a single nonlocal is to
wrap it in a list.
def f():
i = [0]
def g(): i[0] += 1
for j in range(5): g()
On Aug 31, 2:03 pm, "bruno.desthuilli...@gmail.com"
wrote:
> On 31 août, 18:45, Travis Parks wrote:
>
> > I was a little disappointed the other day when I realized that
> > closures were read-only. I like to use closures quite a bit.
>
> They are not _strictly_ read only, but Python being first a
On 31 août, 18:45, Travis Parks wrote:
> I was a little disappointed the other day when I realized that
> closures were read-only. I like to use closures quite a bit.
They are not _strictly_ read only, but Python being first and foremost
an OO language, it's usually way simpler to use OO instead
On Aug 31, 2:18 pm, Ian Kelly wrote:
> On Wed, Aug 31, 2011 at 12:02 PM, Travis Parks wrote:
> > Am I doing something wrong, here? nonlocal isn't registering. Which
> > version did this get incorporated?
>
> 3.0
Ah, okay. It would be really useful for unit testing. Unfortunately, I
want to make
On Wed, Aug 31, 2011 at 12:02 PM, Travis Parks wrote:
> Am I doing something wrong, here? nonlocal isn't registering. Which
> version did this get incorporated?
3.0
--
http://mail.python.org/mailman/listinfo/python-list
On Aug 31, 1:51 pm, Travis Parks wrote:
> On Aug 31, 1:18 pm, Chris Rebert wrote:
>
> > On Wed, Aug 31, 2011 at 9:45 AM, Travis Parks
> > wrote:
> > > I was a little disappointed the other day when I realized that
> > > closures were read-only. I like to use closures quite a bit.
>
> > Assuming
On Aug 31, 1:18 pm, Chris Rebert wrote:
> On Wed, Aug 31, 2011 at 9:45 AM, Travis Parks wrote:
> > I was a little disappointed the other day when I realized that
> > closures were read-only. I like to use closures quite a bit.
>
> Assuming I'm intuiting your question correctly, then you're incorr
On Wed, Aug 31, 2011 at 9:45 AM, Travis Parks wrote:
> I was a little disappointed the other day when I realized that
> closures were read-only. I like to use closures quite a bit.
Assuming I'm intuiting your question correctly, then you're incorrect;
they are "read/write". You just need a `nonlo
On 31 August 2011 17:45, Travis Parks wrote:
> I was a little disappointed the other day when I realized that
> closures were read-only. I like to use closures quite a bit.
>
> Can someone explain why this limitation exists? Secondly, since I can
> cheat by wrapping the thing being closure-ified,
10 matches
Mail list logo