[Tutor] What on earth is happening here ???

Jerry Hill malaclypse2 at gmail.com
Wed Jul 25 17:26:56 CEST 2012


On Wed, Jul 25, 2012 at 11:11 AM, Lipska TheCat
<lipskathekat at yahoo.co.uk> wrote:
>     def getDOMDocument(self):

This defines the method getDOMDocument().

>     def getDOMDocument(self, namespaceUri=__defaultNamespaceUri):

This defines the method getDOMDocument(), replacing the previous definition.

>     def getDOMDocument(self, namespaceUri=__defaultNamespaceUri, qualifiedName=__defaultQualifiedName):

This defines the method getDOMDocument() a third time, replacing the
second definition.


> I have absolutely no idea why a method that requires three arguments is being called when I intend the "no args" method to be called
>
> I'm not asking for a critique of my code and I realise that something spooky
> is going on with the doctype stuff I just need to understand why the 3 arg method is being called instead of the

In python there can only ever be one object bound to a particular
name.  You cannot have three different functions that share the same
name, but have different signatures.  Instead, define a single method
and use default arguments to supply the defaults if someone doesn't
pass in a value.

-- 
Jerry


More information about the Tutor mailing list