using identifiers before they are defined

Jose H. Martinez josehmartinezz at gmail.com
Tue Jun 12 15:02:51 EDT 2012


Seems like what you need is

from othermodule import bb

def aa():
    bb()



On Tue, Jun 12, 2012 at 2:51 PM, Ethan Furman <ethan at stoneleaf.us> wrote:

> 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~
> --
> http://mail.python.org/**mailman/listinfo/python-list<http://mail.python.org/mailman/listinfo/python-list>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120612/3a364036/attachment.html>


More information about the Python-list mailing list