recursive methods require implementing a stack?

Carl Meyer carl at oddbird.net
Wed Apr 6 17:18:25 EDT 2016


On 04/06/2016 03:08 PM, Random832 wrote:
> On Wed, Apr 6, 2016, at 16:21, Charles T. Smith wrote:
>> I just tried to write a recursive method in python - am I right that
>> local
>> variables are only lexically local scoped, so sub-instances have the same
>> ones?  Is there a way out of that?  Do I have to push and pop my own
>> simulated
>> stack frame entry? 
> 
> No, and I'm not sure why you would think that.

Sounds like a confusion that might arise due to using a mutable default
arg? Or generally passing a mutable arg and not understanding Python's
calling semantics?

Carl

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20160406/fbb9ddeb/attachment.sig>


More information about the Python-list mailing list