En Fri, 01 Feb 2008 15:46:05 -0200, Trevor Johnson  
<[EMAIL PROTECTED]> escribió:

> 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?

I think you totally misunderstood the metaclass concept. A class is an  
instance of its metaclass, that is, a metaclass is the "thing" used to  
create a new class. You don't even use (custom) classes in your example.

If you want to make a more generic function, that is, something that works  
for other letters instead of just 'a', you want a function parameter:

>  >>> def testing(searched_letter):
> ...   for word in wordPool:
...

and replace all occurences of 'a' with searched_letter, and 'aaa' with  
searched_letter*3

Usage: testing('a'), it should give the same results as before. Try  
testing('e') etc.

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to