Function declarations ?

Andre Majorel cheney at halliburton.com
Sun Jun 12 15:38:42 EDT 2011


On 2011-06-10, Asen Bozhilov <asen.bozhilov at gmail.com> wrote:
> Andre Majorel wrote:
>
>> Is there a way to keep the definitions of the high-level
>> functions at the top of the source ? I don't see a way to
>> declare a function in Python.
>
> Languages with variable and function declarations usually use
> hoisted environment.

Hoisted ? With a pulley and a cable ?

> JavaScript is the perfect example. Hoisted environment allows
> you to use call expression before the physical declaration of
> the function in the source text.

The issue here is not the ability to call a function before its
declaration. It's being able to do so before its definition.

> Hope this helps, why Python use definitions instead of
> declarations.

It's not either/or. Any language has to provide a way to define
functions whether or not it provides a way to declare them.

Anyway, it seems the Python way to declare a function is

  def f ():
    pass

Thanks everyone.

-- 
André Majorel http://www.teaser.fr/~amajorel/
J'ai des droits. Les autres ont des devoirs.



More information about the Python-list mailing list