This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author paul.j3
Recipients David.Layton, Paolo.Elvati, Stefan.Pfeiffer, bethard, eric.araujo, manveru, paul.j3
Date 2013-09-25.07:15:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
An alternative way to delay the file opening, is to return an instance that has a `filename` attribute, and has an `open` method.  This can be compactly added to the `FileContext` that I defined in the previous patch.  The `FileContext` provides the `_ostest` function (testing using os.access), and wrapper for stdin/out.

    class FileOpener(argparse.FileContext):
        # delayed FileType; alt to use of partial()
        # sample use:
        # with as f:
        def __call__(self, string):
            string = self._ostest(string)
            self.filename = string
            return self
        def open(self):
            return self.__delay_call__(self.filename)()
        file =  property(open, None, None, 'open file property')
Date User Action Args
2013-09-25 07:15:01paul.j3setrecipients: + paul.j3, bethard, eric.araujo, Paolo.Elvati, manveru, Stefan.Pfeiffer, David.Layton
2013-09-25 07:15:01paul.j3setmessageid: <>
2013-09-25 07:15:01paul.j3linkissue13824 messages
2013-09-25 07:15:00paul.j3create