Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Howto MACRO in python ?

Reply
Thread Tools

Re: Howto MACRO in python ?

 
 
Bill Loren
Guest
Posts: n/a
 
      08-12-2003
Welp, I'm trying to implement some kind of tracing mechanism which will
announce every function entrance
in Run-Time.
I wrote a trace function:

DEBUG_LVL = 50

def trace(level, message):
if DEBUG_LVL >= level:
print message

to which I will call with:

trace(40, "%s.%s: entrance" % (__name__, <function_name>) )

upon every function entrance.
(btw I couldn't find any built-in name which correspands to the current
function name so
I type it myslef every trace call)

my wish was to create a MACRO that will save me some text in the code.
something like:
TRACE(40, "entrance")

that will expand into the trace call.

what do you think ?

thanks so much !
~B




----- Original Message -----
From: "Peter Hansen" <(E-Mail Removed)>
Newsgroups: comp.lang.python
To: <(E-Mail Removed)>
Sent: Tuesday, August 12, 2003 1:32 PM
Subject: Re: Howto MACRO in python ?


> Bill Loren wrote:
> >
> > I was looking for a guidance about how to code MACROs in python.
> > any offer ?

>
> A few alternative responses to Irmen's to-the-point answer:
>
> 1. Nobody does.
>
> 2. Those who do, probably use a macro language, like maybe M4.
>
> 3. Nobody does.
>
> 4. What are you actually trying to accomplish, specifically?
>
> -Peter
> --
> http://mail.python.org/mailman/listinfo/python-list



 
Reply With Quote
 
 
 
 
Sean Ross
Guest
Posts: n/a
 
      08-12-2003

"Bill Loren" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> (btw I couldn't find any built-in name which correspands to the current
> function name so
> I type it myslef every trace call)


This recipe will get you the name of the function:
http://aspn.activestate.com/ASPN/Coo...n/Recipe/66062


This recipe appears to be able to wrap methods (not functions) as logging
methods, which may be useful for you:
http://aspn.activestate.com/ASPN/Coo.../Recipe/198078

HTH
Sean


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Howto check value of constants in a macro Richard Meister C Programming 11 11-23-2005 05:28 PM
#define macro to enclose an older macro with strings Dead RAM C++ 20 07-14-2004 10:58 AM
macro name from macro? D Senthil Kumar C Programming 1 09-21-2003 07:02 PM
Re: Howto MACRO in python ? Christian Tismer Python 3 08-13-2003 05:34 PM
Re: Howto MACRO in python ? Bob Gailer Python 0 08-12-2003 05:13 PM



Advertisments