[Tutor] Re: SwishE web interface
Lloyd Kvam
pythonTutor at venix.com
Tue Jun 8 13:19:35 EDT 2004
If the printing is simply to help with debugging and planning the next
step, the pprint module (Pretty Print) should help do the trick nicely.
If you need to provide the formating, then you should be learning the %
format operator. Also, the method for combining a list of strings into
one new string is surprising when you first encounter it.
If you called the list that was returned result_list,
print '\n'.join(result_list)
would:
combine each of the items from result_list into one new string
while inserting a newline ('\n') character between each item
output the new string to stdout
print would provide a final newline character
Warning: The str.join method requires that each item in result_list is a
string (or unicode) object.
On Tue, 2004-06-08 at 12:16, Reed L. O'Brien wrote:
> I replaced for r in results with the line given
>
> return [r.getproperty('searchdocpath') for r in results]
>
> Now it works. I guess I should get out my python book to find out how
> to split that to a vertical list as it rolls right of the page s to the
> right without a scroll. But the return is there.
>
> Thanks Lloyd.
>
> Lloyd Kvam wrote:
> > 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:
> >
>
> >>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