Typing tutor help script needed, please

Mike Meyer mwm at mired.org
Fri Oct 28 14:43:57 EDT 2005


"Throw" <throw at workmail.co.za> writes:

> G'day everyone!
>
> I would like to design typing tutor exercises for Afrikaans (and other
> languages possibly).  This is for a GPL project.  For this, I need a
> script that can extract words from a long list of words, based on which
> letters those words contain, and write then write output to a file.
> Does anyone know of an existing script for this, or can anyone write me
> one, please?

This sounds nearly trivial in Python. More specifics would help.

> Preferably I must be able to extract words which contain only certain
> letters (they need not contain all of those letters, but they may not
> contain any other letters).  It would be nice if I can also extract
> words which do not contain certain letters.

Again, this sounds nearly trivial in Python.

For instance. to get a list of all words that don't contain 'a', you'd
do something  like:

f = open(textfile)
words = f.read().split()
f.close()
selected = [word for word in words if 'a' not in word]

and then selected has the list of words that don't have an 'a' in
them. Tweaking the test the other way - to select words with an 'a',
remove the 'not'. You can combine the tests with 'and' and 'or'.

But without a UI, that's pretty much useless - and you haven't said
what you want the UI to be.

     <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list