From: Tim H. <tim...@ie...> - 2001-04-04 17:58:21
|
RE: [Jython-users] overloading methods ----- Original Message -----=20 From: Brian Zimmer=20 To: Tom Whittaker ; jyt...@li...=20 Sent: Wednesday, April 04, 2001 10:35 AM Subject: RE: [Jython-users] overloading methods The correct way to do this is:=20 def mything(a, b, c=3DNone):=20 """ do something, like check if 'c' is not None """=20 if c:=20 print a, b, c=20 else:=20 print a, b=20 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=3DNone):=20 """ do something, like check if 'c' is not None """=20 if c is not None:=20 print a, b, c=20 else:=20 print a, b=20 Pedantically yours, -tim |