[Tutor] SwishE web interface

Lloyd Kvam pythonTutor at venix.com
Tue Jun 8 11:05:49 EDT 2004


return marks the end of processing in a function.  control is returned
to the caller.

You have multiple results that could be returned as a list.


	return [r.getproperty('searchdocpath') for r in results]
uses "list comprehensions" to return a list of values.  This is a very
handy addition to the language that makes it extremely easy to write a
simple loop and collect the results into a list.





On Tue, 2004-06-08 at 10:20, Reed L. O'Brien wrote:
> I have an html page whose form calls the function in the following.
> 
> import SwishE
>  
> 
> 
> 
> def search(searchWords):
>  
> 
>      # make sure the user provided all the parameters
>      if not (searchWords):
>          return " Nothing to search for. Nothing Found."
> 
>      handle = SwishE.new('/usr/local/swish-e/index.swish-e')
>      search = handle.search('')
>      results = search.execute(searchWords)
> #    return results.hits()
>      for r in results:
>          return r.getproperty('searchdocpath')
> 
> If I:
> return results.hits()
> 
> but
> for r in results:
>          return r.getproperty('searchdocpath')
> 
> only returns the first.  I would like them all returned.  I have been 
> playing around but am in a loop.  Any help would be appreciated.  I know 
> it is a simple solution like converting to a dict or something.  I am 
> humbled by the difficulty of programming.  This is my first non shell 
> script.
> 
> FreeBSD 5.2.1
> apache 2.0.49
> mod_python 3.1.3
> SwishE 0.4
> 
> TIA
-- 

Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice:	603-653-8139
fax:	801-459-9582




More information about the Tutor mailing list