Please translate this easy snip of C++ to Python
Moshe Zadka
moshez at zadka.site.co.il
Sun Feb 4 15:21:32 EST 2001
On 04 Feb 2001 19:59:52 GMT, Phlip <phlip_cpp at my-deja.com> wrote:
> Pythonographers:
>
> Ogle this awesome snip of C++:
>
> #define TRACE_(x) cout << #x ": " << x << endl
You can do it in Python the other way around:
>>> def trace_(x):
... print x+":", eval(x)
...
>>> y = z = 6; animal='lemming'
>>> trace_('y+z')
y+z: 12
>>> trace_('animal')
animal: lemming
HIH!
--
Moshe Zadka <sig at zadka.site.co.il>
This is a signature anti-virus.
Please stop the spread of signature viruses!
Fingerprint: 4BD1 7705 EEC0 260A 7F21 4817 C7FC A636 46D0 1BD6
More information about the Python-list
mailing list