In article <[EMAIL PROTECTED]>,
Simon Forman <[EMAIL PROTECTED]> wrote:
>David Bear wrote:
>> Is there an easy way to get the current level of recursion? I don't mean
.
.
.
>import sys
>
>def getStackDepth():
> '''Return the current call stack depth.'''
> n = 1
> while True:
> try:
> sys._getframe(n)
> except ValueError:
> return n - 1
> n += 1
.
.
.
>This is an evil hack. Never use it.
.
.
.
*This* is evil? I regularly see worse things here in clp.
I'll elaborate slightly: even though I'm among those who regularly
emphasize that certain constructs have nearly no place in applica-
tion, as opposed to "system", programming, counting stack frames to
reach their end seems to me like a minor violation of coding hygiene.
Am I missing something in your suggestion?
--
http://mail.python.org/mailman/listinfo/python-list