[Zope] function pre-declaration?

Charlie Reiman creiman@kefta.com
Mon, 13 Jan 2003 10:16:58 -0800


> -----Original Message-----
> From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of
> philrobinson
> Sent: Monday, January 13, 2003 3:17 AM
> To: Dieter Maurer
> Cc: zope@zope.org
> Subject: Re: [Zope] function pre-declaration?
>
>
> Sorry, I was not clear enough:
> It's a zope python script, so I'm not actually declaring a main() function
>
> I want to do this (in a Zope 'Script (Python)')
> ++++++++++++++++++++++++++++++++++++++++
> # Main starts here
> do something...
> retval = do_util()
> do something else
> return something...
>
> # Utility functions start here
> def util_func():
>   return 'a value'
> ++++++++++++++++++++++++++++++++++++++++
> But I can't because zope doesn't know how to call do_util. In c,
> I could just predeclare the function then use it without worrying about
> the actual definition which comes along later. Is this possible?
> Thanks,

Nope. It's a bad habit for a python programmer anyway. Put everything in
functions, you'll be happier you did in the long run. Something like:

def mymain():
  dosomething...
  retval = util_func()

def util_func():
  return 'avalue'

mymain()