Wednesday, August 23, 2017

recursion in python


limits on the maximum depth of recursion

RecursionError: maximum recursion depth exceeded

https://stackoverflow.com/questions/3323001/what-is-the-maximum-recursion-depth-in-python-and-how-to-increase-it


sys.setrecursionlimit(new_limit_value)

unexpected python scoping

global
nonlocal

https://www.python.org/dev/peps/pep-3104/

https://stackoverflow.com/questions/5218895/python-nested-functions-variable-scoping

nonlocal
https://docs.python.org/3/reference/simple_stmts.html#the-nonlocal-statement

https://stackoverflow.com/questions/5772935/why-doesnt-a-sub-function-inherit-scope-in-python

Sunday, August 20, 2017

io module - file and stream based io in python3

io module @ python 2.6 docs

>>>

New in version 2.6.

The io module provides the Python interfaces to stream handling. Under Python 2.x, this is proposed as an alternative to the built-in file object, but in Python 3.x it is the default interface to access files and streams.

Note

Since this module has been designed primarily for Python 3.x, you have to be aware that all uses of “bytes” in this document refer to the str type (of which bytes is an alias), and all uses of “text” refer to the unicode type. Furthermore, those two types are not interchangeable in the io APIs.

<<<