using identifiers before they are defined
Ethan Furman
ethan at stoneleaf.us
Tue Jun 12 14:51:56 EDT 2012
Julio Sergio wrote:
> Jose H. Martinez <josehmartinezz <at> gmail.com> writes:
>
>>
>> You should define the function first and then call it.
>>
>>
>> def something(i): return i
>>
>>
>> a = something(5)
>>
>>
>> If you want a reference to the function somewhere else you can do this:
>>
>
> I know that. That was what I meant by "changing the order of the definitions
> will work" in my original message.
>
> And I insist in the issue, which is not trivial... In my message I mentioned
> "crossed recursion", and I delve into it here:
>
> Suppose I have to define two functions, aa, and, bb that are designed to call
> each other:
>
> def aa():
> ...
> ... a call of bb() somewhere in the body of aa
> ...
>
> def bb():
> ...
> ... a call of aa() somewhere in the body of bb
> ...
>
>
> Whatever the order of definition of aa and bb the problem remains
No. The reply from MRAB explains this.
~Ethan~
More information about the Python-list
mailing list