Re: Self-identifying functions and macro-ish behavior

2006-02-15 Thread Ben Cartwright
[EMAIL PROTECTED] wrote: > How do I get some > sort of macro behavior so I don't have to write the same thing over and > over again, but which is also not neatly rolled up into a function, > such as combining the return statements with a printing of ? Decorators: http://www.python.org/peps/pep-03

Re: Self-identifying functions and macro-ish behavior

2006-02-15 Thread Iain King
[EMAIL PROTECTED] wrote: > Hi, I was wondering how I may get a python function to know what its > name is without me having to write it manually? For example: > > def func1(): > > print 'func1' > return True > > def func2(): > > print 'func2' > return True > > should be

Re: Self-identifying functions and macro-ish behavior

2006-02-15 Thread Duncan Booth
Michael wrote: > def func2(): > > print > return True > > I imagine this means things like closures which I'm not familiar with > (I'm not a CS person). In this case, each function is part of a class, > so I imagine I can take a dir() of the class if necessary. Use the inspect mod