[Tutor] Alternative File I/O for Tuples (fwd)

Don Parris webdev at matheteuo.org
Tue Jun 28 07:09:20 CEST 2005

On Sun, 26 Jun 2005 16:32:08 -0400
Kent Johnson <kent37 at tds.net> wrote:

> > From: Don Parris <webdev at matheteuo.org>
> > To: Danny Yoo <dyoo at hkn.eecs.berkeley.edu>
> > Subject: Re: [Tutor] Alternative File I/O for Tuples
> > 
> > I guess I'm asking two closely-related questions:
> > (1) how to format the file so it can be readable, and
> If you like the recipe I posted, this could be as simple as 
> mbrPhone = open('mbrPhone.txt', 'w')
> mbrPhone.write(indent(...appropriate args to indent...))
> mbrPhone.close()
> Kent
> _______________________________________________


Just getting back to this - Mondays are always hectic.  This recipe is the
one I saw and like.  It looks cool!  In my brief efforts tinkering with it,
I am not really getting very far.  I saved the recipe, and import it into
the file containing all my database functions.  In one of the
functions, I have the following:

I used the "from tbl_Tabs import *" approach to import the recipe.  If I
should be doing this differently, just say so.

    for record in Results:
        print '%-15s\t%-15s\t%-15s' % record    
# I still want to print to screen, then...

        mbrPhone = open('mbrPhone.txt', 'w')
        mbrPhone.write(indent(record, hasHeader=False, separateRows=True))

I first assumed that "record", and then "Results" could be substituted for
"rows", per the recipe.  I also tried "rows", and assigning "record", and
then "Results" to "rows".  O.k., you can laugh all you want.  I tried
playing with the various arguments, and found that to be of little value.

The traceback refers to a type error: iteration over a non-sequence.  The
query returns a tuple, as I understand it.  I also understand a tuple to be
a sequence.  If this is really as simple as the 3 lines you pointed out
above, I know I'm missing something in the implementation.

evangelinux    GNU Evangelist
http://matheteuo.org/                   http://chaddb.sourceforge.net/
"Free software is like God's love - you can share it with anyone anytime

More information about the Tutor mailing list