Steven W. Orr wrote:
> The problem only happens if I try to modify jj.
It only happens if you try to *bind* the name "jj" to an object inside
the function.
> What am I not understanding?
My guess is that you have a C/C++ view of variables and values, where
variables are locations in memory th
On Wednesday, Jan 9th 2008 at 14:01 -, quoth Fredrik Lundh:
=>Steven W. Orr wrote:
=>
=>> So sorry because I know I'm doing something wrong.
=>>
=>> 574 > cat c2.py
=>> #! /usr/local/bin/python2.4
=>>
=>> def inc(jj):
=>> def dummy():
=>> jj = jj + 1
=>> return jj
=>>
On Jan 9, 3:52 pm, Waldemar Osuch <[EMAIL PROTECTED]> wrote:
> On Jan 9, 11:47 am, "Steven W. Orr" <[EMAIL PROTECTED]> wrote:
>
>
>
> > So sorry because I know I'm doing something wrong.
>
> > 574 > cat c2.py
> > #! /usr/local/bin/python2.4
>
> > def inc(jj):
> > def dummy():
> > jj =
On Jan 9, 11:47 am, "Steven W. Orr" <[EMAIL PROTECTED]> wrote:
> So sorry because I know I'm doing something wrong.
>
> 574 > cat c2.py
> #! /usr/local/bin/python2.4
>
> def inc(jj):
> def dummy():
> jj = jj + 1
> return jj
> return dummy
>
> h = inc(33)
> print 'h() = '
Ben Fisher wrote:
> One way to get this to work is:
>
> def inc(jj):
> def dummy(jj = jj):
> jj = jj + 1
> return jj
> return dummy
>
> h = inc(33)
> print h()
>
> It's not very pretty though, especially when you have many variables
> you want to have in
On Jan 9, 8:24 pm, Mike Meyer <[EMAIL PROTECTED]> wrote:
> On Wed, 9 Jan 2008 13:47:30 -0500 (EST) "Steven W. Orr" <[EMAIL PROTECTED]>
> wrote:
>
>
>
> > So sorry because I know I'm doing something wrong.
>
> > 574 > cat c2.py
> > #! /usr/local/bin/python2.4
>
> > def inc(jj):
> > def dummy()
One way to get this to work is:
def inc(jj):
def dummy(jj = jj):
jj = jj + 1
return jj
return dummy
h = inc(33)
print h()
It's not very pretty though, especially when you have many variables
you want to have in the inner scope.
-Ben
On 1/9/08, Mi
On Wed, 9 Jan 2008 13:47:30 -0500 (EST) "Steven W. Orr" <[EMAIL PROTECTED]>
wrote:
> So sorry because I know I'm doing something wrong.
>
> 574 > cat c2.py
> #! /usr/local/bin/python2.4
>
> def inc(jj):
> def dummy():
> jj = jj + 1
> return jj
> return dummy
>
> h =
Steven W. Orr wrote:
> So sorry because I know I'm doing something wrong.
>
> 574 > cat c2.py
> #! /usr/local/bin/python2.4
>
> def inc(jj):
> def dummy():
> jj = jj + 1
> return jj
> return dummy
>
> h = inc(33)
> print 'h() = ', h()
> 575 > c2.py
> h() =
> Tracebac
So sorry because I know I'm doing something wrong.
574 > cat c2.py
#! /usr/local/bin/python2.4
def inc(jj):
def dummy():
jj = jj + 1
return jj
return dummy
h = inc(33)
print 'h() = ', h()
575 > c2.py
h() =
Traceback (most recent call last):
File "./c2.py", line 10,
10 matches
Mail list logo