Marko Rauhamaa wrote:
> Veek M :
>
>> https://en.wikipedia.org/wiki/Call_stack
>>
>> 'Programming languages that support nested subroutines also have a
>> field in the call frame that points to the stack frame of the latest
>> activation of the procedure that most closely encapsulates the
>> call
Op 13-12-16 om 08:13 schreef Veek M:
> 4. When you call a nested function (decorator), it generally returns a
> wrapper function but I thought he was just returning a reference to a
> function object but obviously since it can see it's environment, how is
> the stack being setup?
Here you are n
http://web.archive.org/web/20111030134120/http://www.sidhe.org/~dan/blog/archives/000211.html
(great tail recursion article - best i've seen! SO doesn't really
explain it unless you already knew it to begin with, but here's the
link:http://stackoverflow.com/questions/310974/what-is-tail-call-opti
Veek M :
> https://en.wikipedia.org/wiki/Call_stack
>
> 'Programming languages that support nested subroutines also have a field
> in the call frame that points to the stack frame of the latest
> activation of the procedure that most closely encapsulates the callee,
> i.e. the immediate scope o
Veek M wrote:
> I was reading the wiki on 'Call stack' because I wanted to understand
> what a traceback object was. My C/C++ isn't good enough to deal with
> raw python source since I have no background in CS. Also, you just
> can't dive into the python src - it takes a good deal of reading and
>
Fredrik Lundh wrote:
> George Sakkis wrote:
>
>> It shouldn't come as a surprise if it turns out to be slower, since the
>> nested function is redefined every time the outer is called.
>
> except that it isn't, really: all that happens is that a new function object
> is created from
> prebuilt p
Thanks everybody for your help!
--
http://mail.python.org/mailman/listinfo/python-list
Duncan Booth wrote:
> Fredrik Lundh wrote:
>
> > George Sakkis wrote:
> >
> >> It shouldn't come as a surprise if it turns out to be slower, since
> >> the nested function is redefined every time the outer is called.
> >
> > except that it isn't, really: all that happens is that a new function
> >
Fredrik Lundh wrote:
> George Sakkis wrote:
>
>> It shouldn't come as a surprise if it turns out to be slower, since
>> the nested function is redefined every time the outer is called.
>
> except that it isn't, really: all that happens is that a new function
> object is created from prebuilt par
George Sakkis wrote:
> It shouldn't come as a surprise if it turns out to be slower, since the
> nested function is redefined every time the outer is called.
except that it isn't, really: all that happens is that a new function object is
created from
prebuilt parts, and assigned to a local varia
Georg Brandl wrote:
> That's right. However, if the outer function is only called a few times
> and the nested function is called a lot, the locals lookup for the
> function name is theoretically faster than the globals lookup. Also,
> in methods you can use closures, so you don't have to pass, fo
George Sakkis wrote:
> Ben Finney wrote:
>
>> "Gregory Petrosyan" <[EMAIL PROTECTED]> writes:
>>
>> > I often make helper functions nested, like this:
>> >
>> > def f():
>> > def helper():
>> > ...
>> > ...
>> >
>> > is it a good practice or not?
>>
>> You have my blessing. Used we
Ben Finney wrote:
> "Gregory Petrosyan" <[EMAIL PROTECTED]> writes:
>
> > I often make helper functions nested, like this:
> >
> > def f():
> > def helper():
> > ...
> > ...
> >
> > is it a good practice or not?
>
> You have my blessing. Used well, it makes for more readable code.
"Gregory Petrosyan" <[EMAIL PROTECTED]> writes:
> I often make helper functions nested, like this:
>
> def f():
> def helper():
> ...
> ...
>
> is it a good practice or not?
You have my blessing. Used well, it makes for more readable code.
> What about performance of such const
Lawrence D'Oliveiro wrote:
> >BUT 'b' and 'c' simply do not exist outside the 'a' world.
>
> It's worth distinguishing between the _names_ 'b' and 'c' and the
> _functions_ referred to by those names. The _names_ certainly do not
> exist outside of the scope of the function referred to by 'a' (any
In article <[EMAIL PROTECTED]>,
"Thomas Bartkus" <[EMAIL PROTECTED]> wrote:
>Your function 'a' is it's own little world where functions 'b' and 'c'
>exist.
>Your code inside 'a' can call 'b' or 'c' - neat as you please.
>
>BUT 'b' and 'c' simply do not exist outside the 'a' world.
It's worth dis
Szabolcs Berecz wrote:
> On 14 Apr 2006 04:37:54 -0700, [EMAIL PROTECTED]
> <[EMAIL PROTECTED]> wrote:
>
>>def a():
>> def b():
>>print "b"
>> def c():
>>print "c"
>>
>>how can i call c() ??
>
>
> Function c() is not meant to be called from outside function a().
> That's what a nested
Thomas Bartkus wrote:
> I, for one, am so glad to have nested functions again ;-)
again ?
Python has always supported nested functions. it's the scoping rules
that have changed; before the change from LGB to LEGB, you had to
explictly import objects from outer scopes.
--
http://mail.pytho
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> hi
> just curious , if i have a code like this?
>
> def a():
> def b():
> print "b"
> def c():
> print "c"
>
> how can i call c() ??
Your function 'a' is it's own little world where functions 'b' and 'c'
exist.
Your code ins
[EMAIL PROTECTED] wrote:
> just curious , if i have a code like this?
>
> def a():
> def b():
> print "b"
> def c():
> print "c"
>
> how can i call c() ??
in the same way as you'd access the variable "c" in this example:
def a():
c = 10
(that is, by calling the function
On 14 Apr 2006 04:37:54 -0700, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> def a():
> def b():
> print "b"
> def c():
> print "c"
>
> how can i call c() ??
Function c() is not meant to be called from outside function a().
That's what a nested function is for: localizing it's usage a
[EMAIL PROTECTED] wrote:
> hi
> just curious , if i have a code like this?
>
> def a():
> def b():
> print "b"
> def c():
> print "c"
>
> how can i call c() ??
c is a name in the local scope of a(). You can call c from within a,
where the name is in scope, or you can return c or in
22 matches
Mail list logo