Meta Class

Trevor Johnson trevorpython at gmail.com
Fri Feb 1 12:46:05 EST 2008


Hi;
I think I have a good candidate for a meta class here. Never done this
before and would like someone to help. In the code that follows, there is
one variable that needs to be changed: the letter 'a' as inserted in
construction of the variable 'word'. In other applications, I will need to
change that to two variables, but they are independent within this code. How
do I go about abstracting these variables to make a meta class?
TIA,
Trevor

 >>> def testing():
...   for word in wordPool:
...     i = 0
...     i2 = 0
...     i3 = []
...     new = []
...     for letter in word:
...       if letter == 'a':
...         i3.append(i2)
...         i2 += 1
...         new.append(word[0:i + 1] + 'a' + word[i + 1:len(word)])
...       i += 1
...       i2 += 1
...     i4 = 0
...     i5 = 0
...   for word in new:
...     wordPool.append(word)
...   print 'i3: ', i3
...   for word in wordPool:
...     while len(i3) > i4:
...       new.append(word[0:i3[i4]] + 'a' + word[i3[i4]:len(word)])
...       i4 += 1
...       while len(i3) > i5:
...         new.append(word[0:i3[i5] + 1] + 'a' + word[i3[i5] +
1:len(word)])
...         i5 += 1
...     i4 = 0
...   for word in new:
...     i = 2
...     while i < len(word):
...       if word[i - 2] == word[i - 1]:
...         if word[i - 1] == word[i]:
...           new.remove(word)
...       i += 1
...   for word in new:
...     if word[len(word) - 3:len(word)] == 'aaa':
...       new.remove(word)
...   for word in new:
...     wordPool.append(word)
...   i = 0
...   i2 = 0
...   for word in wordPool:
...     for test in wordPool:
...       if i != i2:
...         if test == word:
...           wordPool.remove(test)
...       i2 += 1
...     i += 1
...   for word in wordPool:
...     print 'second: ',word
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080201/f1db7bb9/attachment.html>


More information about the Python-list mailing list