----- Original Message -----
From: Brian Zimmer
To: Tom Whittaker ; jython-users@lists.sourceforge.net
Sent: Wednesday, April 04, 2001 10:35 AM
Subject: RE: [Jython-users] overloading methods

The correct way to do this is:

def mything(a, b, c=None):
 """ do something, like check if 'c' is not None """
 if c:
  print a, b, c
 else:
  print a, b

You may want to be careful testing for c being true rather than testing None specifically since:

    mything("spam", "eggs", []) # or () or "" or 0 or some instances.

will take the second branch which may not be want you want. It's probably better to use:

def mything(a, b, c=None):
 """ do something, like check if 'c' is not None """
 if c is not None:
  print a, b, c
 else:
  print a, b

 

Pedantically yours,

-tim