[Tutor] filtering within a function.
Tesla Coil
tescoil@irtc.net
Mon, 12 Mar 2001 12:10:32 -0500
Revising cipher.py...
http://www.lowerstandard.com/python/cipher.py
to eliminate import of string, and discovered
that the unstray function is bugged something
awful (guess it usually gets the right input;
this has gone unnoticed for a couple months).
Given:
>>> foo = list('UPPERlowerUPPER12345')
This appears to work:
>>> uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
>>> def f(x): return x in uppercase
...
>>> filter(f, foo)
['U', 'P', 'P', 'E', 'R', 'U', 'P', 'P', 'E', 'R']
Can't seem to make it work inside the function.