
Steve Howell wrote:
--- Ron Adam <rrr@ronadam.com> wrote:
# Tests
def a_g(s): return s[0].lower() in "abcdefg"
def h_m(s): return s[0].lower() in "hijklm"
def n_z(s): return s[0].lower() in "nopqrstuvwxyz"
decmps = [a_g, h_m, n_z] ag, hm, nz, other = decomp(src, *decmps)
print 'ag =', ag print 'hm =', hm print 'nz =', nz print 'other =', other
-------------------
ag = ['c8WQe60G6J', 'EMY7O8qzTg'] hm = ['lDunyeOM98', 'LJuPg8ncZd'] nz = ['uhhuhd9YdO', 'qAuQvfTc6N', 'vpJz47pkP5', 'YOq6m4IXBn'] other = ['8JE6PuXxBz', '4ttyMdpuQY']
Am I misunderstanding (de-comprehensing) something here? How does the code above return those result sets? Or, more specifically, why does ag include 'T' in its results set?
The data in this case simulates 10 digit partnumbers which can include a-z, A-Z, and 0-9. It doesn't alter the data, it just sorts it into smaller groups according to some predefined tests. In this case.. it's only testing the first letter of each item. What is tested is entirely up to you. You could have lists of records as your data and test fields and divide the data according to that. Cheers, Ron