about functions question

Diez B. Roggisch deets at nospam.web.de
Thu Oct 25 08:26:42 EDT 2007


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>
>     print qq()
> NameError: name 'qq' is not defined
> 
> 
> Or onli possible:
> 
> def main():
>  print qq()
> 
> def qq():
>   return 'hello'
> 
> main()

Yes. That's the way to go.

Diez



More information about the Python-list mailing list