En Fri, 01 Aug 2008 16:21:26 -0300, kj <[EMAIL PROTECTED]> escribi�:

In <[EMAIL PROTECTED]> Miles <[EMAIL PROTECTED]> writes:

On Wed, Jul 30, 2008 at 5:52 PM, kj <[EMAIL PROTECTED]> 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.)

One thing I can think of: The help system (and the code autocompleter found in some editors, and other introspection tools) can't tell you the name/number/default value of the arguments anymore: they're all masked into a generic *args

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to