functions

Almar Klein almar.klein at gmail.com
Fri Nov 28 03:22:59 EST 2008


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 <girish.cfc at gmail.com>

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20081128/07c10e5c/attachment-0001.html>


More information about the Python-list mailing list