[Patches] [ python-Patches-1613500 ] Write mode option for fileinput module.

SourceForge.net noreply at sourceforge.net
Mon Dec 18 20:33:56 CET 2006


Patches item #1613500, was opened at 2006-12-11 21:16
Message generated for change (Comment added) made by antroy
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1613500&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Library (Lib)
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Anthony Roy (antroy)
Assigned to: Nobody/Anonymous (nobody)
Summary: Write mode option for fileinput module.

Initial Comment:
The current implementation of the fileinput module allows an optional 'mode' keyword argumant to the FileInput initializer and the input() convenience function.

The attached patch provides a similar write_mode keyword argument with which to specify the write mode when the 'inplace' option is used.

Included in the patch file are:

1) Changes to the fileinput module to accomodate the optional write mode option

2) Additions to the fileinput tex documentation.

3) A refactored test module, where the tests have been reorganised into TestCase subclasses, and new tests added for the new functionality.

----------------------------------------------------------------------

>Comment By: Anthony Roy (antroy)
Date: 2006-12-18 19:33

Message:
Logged In: YES 
user_id=1666022
Originator: YES

The restriction isn't entirely arbitrary as far as I can see. If you allow
the combination of inplace and openhook, then you will also need a
writehook option, or the ability to specify a pair of hook function for the
openhook. For example, there is a function provided for opening a
compressed file for reading. In order to do an inplace edit, you would need
to provide a write hook to compress the data on the way back in.

I think that the implementation of such a change would be open for
discussion, and is beyond the scope of a minor change as suggested in this
patch. (Perhaps the topic for a future PEP).

----------------------------------------------------------------------

Comment By: Martin Kammerhofer (mkam)
Date: 2006-12-15 13:10

Message:
Logged In: YES 
user_id=1656067
Originator: NO

The restriction that you cannot use inplace and openhook together seems
somewhat
arbitrary to me. Have you considered lifting it? From looking at the
source it
seems not too hard to do. There are uses for e.g. inplace editing
compressed files.
This would fit nicely with your patch.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1613500&group_id=5470


More information about the Patches mailing list