overriding file.readline: "an integer is required"

kj socyl at 987jk.com.invalid
Fri Aug 1 21:21:26 CEST 2008

In <mailman.953.1217472439.922.python-list at python.org> Miles <semanticist at gmail.com> writes:

>On Wed, Jul 30, 2008 at 5:52 PM, kj <socyl at 987jk.com.invalid> wrote:
>> I know that I could rewrite the method like this:
>>    def readline(self, size=None):
>>        if size == None:
>>            line = self.file.readline()
>>        else:
>>            line = self.file.readline(size)
>>        # etc., etc.
>> ...but this seems to me exceptionally awkward.  (Actually, it's worse
>> than awkward: it fails to complain when the overriding method is
>> called with the argument None.

>You could of course do:

>    def readline(self, *args):
>        line = self.file.readline(*args)
>        # etc., etc.

>But this has its drawbacks.

Like what?  (I'm pretty new to Python and these drawbacks are not
obvious to me.)


NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.

More information about the Python-list mailing list