Applications/examples of some advanced Py features, please !

Az Tech aztech1200 at
Sat Jan 4 16:12:12 CET 2003

Hi Python gurus,

Can anyone please give some examples / applications of the use of the
following advanced (advanced to me, at least :-) features of Python :

1. lambda
(I understand the basic usage - simple examples - but I'm not able to
'wrap my head around' how to use it a way that will be of benefit.
Pls. see below for more on this.

2. nested functions - a little info was given by Danny in reply to my
earlier post on local-static variables, but I would like more.

3. Thoughts on implementing Interfaces in Py - a la Java interfaces.

I have, and will be doing more, on reading the docs and Googling for
this, but would anyway appreciate pointers/inputs from those who know
this stuff.

I have a specific reason for the above questions - apart from general
interest, of course - I am planning to write a game-playing program in
Py which will have features somewhat AI - ish, such as learning from
past games. I.e. it will be computer vs. human player, and I want to
try and make the computer learn from the saved history of past games -
wins/losses. I don't have any background in AI; nor much in functional
programming. I do understand recursion though, and basic Python
functional constructs like map, reduce and filter - at least the
simpler usages.

I suspect that some of the above 3 points will help me to write my app
in a better way. though not sure, of course. Hence the request for

For all of the above 3 points, I'm interested in :

 - code examples of their use

 - knowing in what way their use makes code simpler, or maybe makes
code possible that could not be written otherwise ('possible' in
practical terms - I'm - vaguely - aware of the fact that all languages
are supposed to be theoretically 'Turing-equivalent' - but what I mean
is that if something is going to take a huge amount more code in some
other language, or jumping through hoops, then I don't call it
practically equivalent).

Thanks ! I'll summarize and post more details on my progress with the
game, once I make some.


More information about the Python-list mailing list