extending file?

Jeremy Jones zanesdad at bellsouth.net
Tue Nov 2 09:22:09 EST 2004


Peter Hansen wrote:

> Chris Cioffi wrote:
>
>> Are there any docs or examples of extending the file type?  I work
>> with EDI messages that are very like text files, just with a few
>> quirks. ;-)  and I was wondering if I could strech and twist the built
>> in file type to make things a bit faster and more full featured.
>>
>> Specifically I would need to alter the iterator and ideally the line 
>> terminitor.
>
>
> It's unclear what you want to do.  Can you provide an example?
>
> Also consider whether you can achieve what you want merely
> by creating your own "file-like" object that wraps the
> standard file type.  This is the usual way to proceed.
>
> -Peter

I should really wait for the OP, but I've had too much caffeine this 
morning to just sit still.  An EDI message is a (fairly well) structured 
string of text (let's just say a file for now) that may consist of 
multiple interchanges, each interchange consisting of multiple segments 
(at least two, and each segment having a specific character denoting its 
end - all segments in an interchange will have the same segment 
terminator) and each segment consisting of multiple elements.  I believe 
the OP wants to be able to specify what character the file object will 
recognize as a line terminator (rather than the standard \n or \r\n), 
presumably so he can tell it that a segment terminator is the line 
terminator, do a readline(), and get an EDI segment instead of a 
"traditional" line of text.  Having dealt with EDI for nearly 6 years, I 
could see the benefit of this.  While I'm currently headed down the FSM 
route, it would be interesting to see the above mentioned alternative.

Jeremy Jones



More information about the Python-list mailing list