Andre Majorel <che...@halliburton.com> wrote:
>
>Anyway, it seems the Python way to declare a function is
>
>  def f ():
>    pass

No, that DEFINES a function.  There is no way to declare a function in
Python.  It isn't done, because it isn't necessary.

That code doesn't do what you think it does.  Example:

    def f():
        pass

    g = f

    def f():
        return 3

    print g()

That prints "none".  That module has two definitions of f, not one.  The
meaning of the name "f" changes partway through the module.

Python is not C.  You need to use Python habits, not C habits.  What
construct led you to think you need to declare a function like that?  This
code, for example, works fine:

    def g():
        return f()
    def f():
        return 3
    print g()

The name "f" does not have to be defined until the function "g" is actually
executed.
-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to