Re: about functions question

2007-10-26 Thread Bruno Desthuilliers
Neil Cerutti a écrit : On 2007-10-25, Bruno Desthuilliers [EMAIL PROTECTED] wrote: The canonical case for small scripts is to have first all functions and globals defined, then the main code protected by a guard, ie: There's no reason to protect your main code in a small script. I

Re: about functions question

2007-10-26 Thread Neil Cerutti
On 2007-10-26, Bruno Desthuilliers [EMAIL PROTECTED] wrote: Neil Cerutti a écrit : On 2007-10-25, Bruno Desthuilliers [EMAIL PROTECTED] wrote: The canonical case for small scripts is to have first all functions and globals defined, then the main code protected by a guard, ie: There's no

about functions question

2007-10-25 Thread NoName
I try it: def b(): ... a() ... def a(): ... b() ... b() it's not work. Is it possible pre-define function like in c++ or place functions code after main block? int a(); int b(); int main () { ... a(); ... } int a() { ... b(); ... } int b() { ... a(); ... } =) sorry for my

Re: about functions question

2007-10-25 Thread Diez B. Roggisch
NoName schrieb: I try it: def b(): ... a() ... def a(): ... b() ... b() it's not work. It works. def a(): print a b() def b(): print b print a # not calling! b() But if you really call a in b, you create an endless loop. In all

Re: about functions question

2007-10-25 Thread George Sakkis
On Oct 25, 2:28 am, NoName [EMAIL PROTECTED] wrote: I try it: def b(): ... a() ... def a(): ... b() ... b() it's not work. It sure does. Please post full code and error message, something else is wrong, not the cyclic reference. George --

Re: about functions question

2007-10-25 Thread Marc 'BlackJack' Rintsch
On Thu, 25 Oct 2007 06:28:16 +, NoName wrote: I try it: def b(): ... a() ... def a(): ... b() ... b() it's not work. What do you mean by not working? At the time `b()` is called, both functions are defined so it should working. Or at least it's not the problem

Re: about functions question

2007-10-25 Thread Arnaud Delobelle
On Oct 25, 7:28 am, NoName [EMAIL PROTECTED] wrote: I try it: def b(): ... a() ... def a(): ... b() ... b() it's not work. Probably all those dots! Is it possible pre-define function like in c++ or place functions code after main block? Python binds names to objects

Re: about functions question

2007-10-25 Thread Arnaud Delobelle
On Oct 25, 10:30 am, Arnaud Delobelle [EMAIL PROTECTED] wrote: [...] look for the object currently bound to the name 'b' in the global dictionary, and execute the __call__ method of that object with no arguments This is what happens at runtime. Rereading, I thought I hadn't made it clear. --

Re: about functions question

2007-10-25 Thread NoName
sorry! Yes it's work. What about 2 question? Can i put function after main block? print qq() def qq(): return 'hello' Traceback (most recent call last): File C:\Python25\projects\indexer\test.py, line 1, in module print qq() NameError: name 'qq' is not defined Or onli possible: def

Re: about functions question

2007-10-25 Thread Diez B. Roggisch
NoName wrote: sorry! Yes it's work. What about 2 question? Can i put function after main block? print qq() def qq(): return 'hello' You can't call a thing before it is defined. Traceback (most recent call last): File C:\Python25\projects\indexer\test.py, line 1, in module

Re: about functions question

2007-10-25 Thread Bruno Desthuilliers
NoName a écrit : sorry! Yes it's work. What about 2 question? Can i put function after main block? print qq() def qq(): return 'hello' Where's your main block here ? Traceback (most recent call last): File C:\Python25\projects\indexer\test.py, line 1, in module print qq()

Re: about functions question

2007-10-25 Thread Neil Cerutti
On 2007-10-25, Bruno Desthuilliers [EMAIL PROTECTED] wrote: The canonical case for small scripts is to have first all functions and globals defined, then the main code protected by a guard, ie: There's no reason to protect your main code in a small script. if __name__ == '__main__':

Re: about functions question

2007-10-25 Thread Chris Mellon
On 10/25/07, Neil Cerutti [EMAIL PROTECTED] wrote: On 2007-10-25, Bruno Desthuilliers [EMAIL PROTECTED] wrote: The canonical case for small scripts is to have first all functions and globals defined, then the main code protected by a guard, ie: There's no reason to protect your main code