Meta Class

Trevor Johnson trevorpython at gmail.com
Mon Feb 4 09:52:39 EST 2008


You're right I totally misunderstood it. And your idea is obvious and simple
enough :)

On Feb 1, 2008 6:33 PM, Gabriel Genellina <gagsl-py2 at yahoo.com.ar> wrote:

> En Fri, 01 Feb 2008 15:46:05 -0200, Trevor Johnson
> <trevorpython at gmail.com> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080204/d7c7bdb4/attachment-0001.html>


More information about the Python-list mailing list