Should I write a book on Python Metaprogramming ?

Jack Diederich jack at performancedrivers.com
Mon May 5 06:20:25 EDT 2003


All my comments should be taken as a consumer's perspective.  I'll leave
the publishing comments to those who know something about it.

On Mon, May 05, 2003 at 02:19:59AM -0400, David Mertz wrote:
> So here's my questions to c.l.py.  Would you want a book along the below
> lines at all?  Do you only want it if it focusses closely on Python?  Or
> would you rather have a book that addressed several languages fairly
> equally, with Python just one among them?  Are the outlined chapters the
> ones you would expect?  Or is something missing?  Or unnecessary?
> Assuming the suggested chapters point in the right directions, what
> specific topics would you want to see covered within each one?

I would definitely buy this book, but you are right that it will have a smaller
distribution than a 'intro to *' or '* cookbook' volume.  Based on the recent
threads about metaclasses and searching for the meaning of aspect oriented
programming there is at least some kind of market.

GoF's "Design Patterns" only suffered slightly for being C++ centric. Keeping
your book python centric would be fine since python supports most the
concepts you want to talk about.  I bought the whole section of python
books at Microcenter when I started with it, and had to hunt and seek for
ideas/idioms that I hadn't picked up in another language.  They felt a bit
'intro' even if it wasn't in the title.  A good advanced book would be welcome.

In fact, if the Arc (or maybe it was Io?) guy is right languages get 
popularized by the elite.  If /the/ textbook on meta programming used python,
advanced students would use python and the snowball would grow.

> 
> Title:    _Overtures for Metaprogramming_
>
A five dollar word for 'intro' still sounds too much like 'intro' for my
tastes *wink*.  You are a philosiphy guy, how about "The Phenomenology of
Programming" [definitely just kidding there].

> Address:  99 2nd Street
>           Turners Falls MA 01376 USA
Boston is a hike for you, but there is a python meetup this thursday
in Davis Sq (by the viral meetup.com).  I'd be a happy sounding board,
as I'm sure everyone else would be if you want to try some ideas.

> 
>   In my programming writing, I have frequently addressed
>   theoretical topics, such as that in this book, but always with a
>   deliberate sense of their application to practical problems in
>   application development. Perhaps because of my mixed background
>   as an academic and developer, I strike an unusual balance
>   between the abstract and the practical--or better still, unify
>   the two levels within discussion of concrete techniques,
>   libraries, etc.
Sounds good, Stevens' "Advanced Programming in the UNIX Environment" was
excellent in this respect.  He discussed whole OS topics that you couldn't
pick up just by reading man pages, and built them up in examples.

>   Some longer notes on intended book contents are at
>   <http://www.gnosis.cx/secret/meta-programming.notes>.
I would leave out __slots__.  They don't have an interesting concept behind
them, they are just an implementation detail.  I would mention at least in
passing that python uses a BNF grammar to define and build itself.  Very 
fitting for a metaprogramming language, you might even spin some examples 
from there[1].

>   VII.  Code generators and code parsers.
Do people really write code generators in python that output python?  I'm not 
sure I see the point if you have metaclasses and inspection.  Do you mean like
a pickled state machine?  Or outputting C from python?  Then again, maybe 
that's why I'll have to buy the book.

-jack

[1] Without checking, I think you've written about PLY too.
    search groups.google for my past posts linking to a refactored PLY using
    meta classes.





More information about the Python-list mailing list