Building Very Large Records
Alex Martelli
aleaxit at yahoo.com
Fri Sep 10 18:17:27 EDT 2004
Greg Lindstrom <greg.lindstrom at novasyshealth.com> wrote:
> Hello-
>
> I am working on a routine to pull information from an Oracle database and
> format it into fixed-length records. My problem is that the record layout
> is quite long (over 500 bytes) and contains dozens of fields. How would
> *you* go about building such a beast? I know that using the += operator is
> a bad idea, as it creates a new copy of the string each time. How about the
> struct.pack() method? A very big '%-12.12s%-50.50s.......' statement?
Yep, except that what you're quoting ain't a statement, just a string.
But put a % after it and the right tuple after that, and you''re going
somewhere!-)
Alex
More information about the Python-list
mailing list