Hi, I'm writing a python Extension, which searches in any folder recursively. This means the code: def foo(self,counter=None): some code if bar == somewhat: foo(counter=some_int) When i run this through zope a error occours. Zope says expected 1 argument got 0. My question is what argument is missing. mfg as
I'd imagine self would be missing. There would seem to be two ways to 'fix' this, I'll leave it as an exercise for the reader to discuss which is best. Option 1: def foo(self,counter=None): some code if bar == somewhat: self.foo(counter=some_int) Option 2: def foo(self,counter=None): some code if bar == somewhat: foo(self,counter=some_int) hth Phil phil.harris@zope.co.uk ----- Original Message ----- From: "Andre Schubert" <andre.schubert@geyer.kabeljournal.de> To: <zope-dev@zope.org> Sent: Friday, May 26, 2000 9:02 AM Subject: [Zope-dev] Recursion
Hi,
I'm writing a python Extension, which searches in any folder recursively.
This means the code:
def foo(self,counter=None): some code if bar == somewhat: foo(counter=some_int)
When i run this through zope a error occours. Zope says expected 1 argument got 0. My question is what argument is missing.
mfg as
_______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
There would seem to be two ways to 'fix' this, I'll leave it as an exercise for the reader to discuss which is best.
Option 1: def foo(self,counter=None): some code if bar == somewhat: self.foo(counter=some_int) Option 1 has a problem. If you give it a different name in dtml, e.g. bar and call it: <dtml-var "bar(counter=5)"> then self is a reference to the folder and self.foo doesn't exist. If there is a different method 'foo' in the folder that other method will be called instead.
Option 2: def foo(self,counter=None): some code if bar == somewhat: foo(self,counter=some_int)
This one should work as advertised. (Unless you redefine foo in the python module in which case you get what you deserve). -- Duncan Booth duncan@dales.rmplc.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? http://dales.rmplc.co.uk/Duncan
participants (3)
-
Andre Schubert -
Duncan Booth -
Phil Harris