Idiomatic backtracking in Python

MRAB python at
Mon Jan 26 01:43:24 CET 2015

On 2015-01-26 00:32, Ben Finney wrote:
> Johannes Bauer <dfnsonfsduifb at> writes:
>> So, I would like to ask if you have a Pythonic approach to
>> backtracking problems? If so, I'd love to hear your solutions!
> I'm not aware of what the problem is. “Back-tracking” doesn't have a
> general meaning I recognise beyond random access into a data structure.
> So a Python list is the obvious starting point.
> Do you have a specific meaning of “back-tracking” that implies
> particular problems that are difficult to solve?
I believe he's talking about trying different alternatives until one
works. You get it in matching regexes (well, when using the NFA
approach as used in the re module, Perl regexes, etc, anyway).

More information about the Python-list mailing list