Re: [Tutor] More Pythonesque or a more efficient method

2008-10-07 Thread W W
On Tue, Oct 7, 2008 at 5:58 PM, Emile van Sebille <[EMAIL PROTECTED]> wrote: > Robert Berman wrote: > >> Hi, >> >> The below script which prints anagrams available for any word available >> within a given database. It does work, but it is not very fast. I am >> relatively certain there are more P

Re: [Tutor] More Pythonesque or a more efficient method

2008-10-07 Thread Emile van Sebille
Robert Berman wrote: Hi, The below script which prints anagrams available for any word available within a given database. It does work, but it is not very fast. I am relatively certain there are more Python friendly coding techniques but I am more concerned with a faster algorithm. You mig

Re: [Tutor] More Pythonesque or a more efficient method

2008-10-07 Thread Robert Berman
Yet another approach to experiment with. Thank you all very much, Robert Kent Johnson wrote: On Tue, Oct 7, 2008 at 1:15 PM, Richard Lovely <[EMAIL PROTECTED]> wrote: In a slightly related matter, Is is possible to use all() with a list comprehension to check if a word contains a

Re: [Tutor] More Pythonesque or a more efficient method

2008-10-07 Thread Kent Johnson
On Tue, Oct 7, 2008 at 1:15 PM, Richard Lovely <[EMAIL PROTECTED]> wrote: > In a slightly related matter, Is is possible to use all() with a list > comprehension to check if a word contains all of the letters of > another? Sure. In [1]: all(letter in 'abcde' for letter in 'cde') Out[1]: True In

Re: [Tutor] More Pythonesque or a more efficient method

2008-10-07 Thread Richard Lovely
In a slightly related matter, Is is possible to use all() with a list comprehension to check if a word contains all of the letters of another? -- Richard "Roadie Rich" Lovely, part of the JNP|UK Famile www.theJNP.com ___ Tutor maillist - Tutor@python.

Re: [Tutor] More Pythonesque or a more efficient method

2008-10-05 Thread Robert Berman
Kent, Thank you for two excellent suggestions. I will implement your  suggestion of indexing by the sorted letters in the word. Robert Kent Johnson wrote: On Sun, Oct 5, 2008 at 1:52 PM, Robert Berman <[EMAIL PROTECTED]> wrote: The database item consists of the key; the actual

Re: [Tutor] More Pythonesque or a more efficient method

2008-10-05 Thread Kent Johnson
On Sun, Oct 5, 2008 at 1:52 PM, Robert Berman <[EMAIL PROTECTED]> wrote: > The database item consists of the key; the actual word, and the value, the > size as a string. For example, the word 'myth' is represented as key= > 'myth', value = '4'. I think the slow part of the algorithm is the script

[Tutor] More Pythonesque or a more efficient method

2008-10-05 Thread Robert Berman
Hi, The below script which prints anagrams available for any word available within a given database. It does work, but it is not very fast. I am relatively certain there are more Python friendly coding techniques but I am more concerned with a faster algorithm. The database item consists of