You could pass it as an argument:

==== c:\script1.py
foo(whatever_arguments_you_need, caller=None):
    ....

==== c:\script2.py
import script1
script1.foo(blabla, caller=__file__)

Other than that I would not know. Maybe the inspect module can
help you but as far as I can see, it doesn't. I'm also not sure if it
would be a nice way to solve your problem (what is your problem?),
if it is even possible. Additionally, the function could be called from
the command line rather than from a file.

  Almar


2008/11/28 Girish <[EMAIL PROTECTED]>

> Hello,
>
> Is ter any way to identify the file name and the path in which the
> function is called.
>
> for example: if the function definition is in the file c:\script1.py
> and if I call this function in a script: c:\script2.py than in the
> function definition part(script1.py) some how I need to know that its
> called in c:\script2.py.
>
> Thanks,
> Giri
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to