No macros in Python

Lulu of the Lotus-Eaters mertz at gnosis.cx
Sun Dec 15 22:17:02 EST 2002


Mike Meyer <mwm at mired.org> wrote previously:
|A proper macro facility in python should let me write:
|        with_output_to_file "filename":
|            code that will be executed
|            with print statement output
|            going into filename
|        code that will have
|        print statement output
|        going to where ever it was
|        going before the macro

You mean like:

  orig = sys.stdout               # or just use sys.__stdout__ later
  sys.stdout = open('fname','w')  # w/ output to...
  print this, that, other
  sys.stdout = orig               # or sys.stdout = sys.__stdout__
  print original, output, destination

I know it's not -exactly- the same thing... the Python version is
shorter and clearer.

|It should also allow me to add conditional expressions to the
|language, ala the C ?: operator.

Shudder!  I pray to Guido this will never come about.

I'm not necessarily opposed to a ternary operator.  In fact, I'd
probably like one.  But I am opposed down to my bones to a ternary
operator defined by an individual programmer in whatever idiosyncratic,
perhaps inadequately tested, fashion she chooses.

Yours, Lulu...

--
 mertz@  _/_/_/_/ THIS MESSAGE WAS BROUGHT TO YOU BY: \_\_\_\_    n o
gnosis  _/_/             Postmodern Enterprises            \_\_
.cx    _/_/                                                 \_\_  d o
      _/_/_/ IN A WORLD W/O WALLS, THERE WOULD BE NO GATES \_\_\_ z e





More information about the Python-list mailing list