Le dimanche 13 août 2006 14:18, John Machin a écrit :
> I don't usually go for one-liners, especially ugly ones like
> "inspect.stack()[1][1:3]" but it avoids the risk of hanging on to a
> reference to the frame object -- see the warning in the inspect docs.
Yes, my mistake, thanks for pointing th
Maric Michaud <[EMAIL PROTECTED]> writes:
> Sure, try :
>
> In [46]: import inspect
>
> In [47]: c=inspect.currentframe()
>
> In [48]: c.f_lineno
> Out[48]: 1
>
> In [49]: c.f_code.co_filename
> Out[49]: ''
Thanks a lot - that was just what I wanted.
Regards - Joakim
--
Joakim Hove
hove AT
Joakim Hove wrote:
> Hello,
>
> i have simple[1] function like this:
>
>def log_msg(msg , file , line):
>print "%s:%s %s" % (file,line,msg)
>
> the file and line arguments should be the filename and linenumber of
> the source file where the function is called. If this were C I would
>
Le dimanche 13 août 2006 13:31, Joakim Hove a écrit :
> Hello,
>
> i have simple[1] function like this:
>
>def log_msg(msg , file , line):
>print "%s:%s %s" % (file,line,msg)
>
> the file and line arguments should be the filename and linenumber of
> the source file where the function
Hello,
i have simple[1] function like this:
def log_msg(msg , file , line):
print "%s:%s %s" % (file,line,msg)
the file and line arguments should be the filename and linenumber of
the source file where the function is called. If this were C I would
have used the __FILE__ and __LINE_