Out-denting multiline comments

Delaney, Timothy tdelaney at avaya.com
Tue Aug 13 01:41:10 CEST 2002

> From: Steve Holden [mailto:sholden at holdenweb.com]
> "Delaney, Timothy" <tdelaney at avaya.com> wrote ...
> > > From: bokr at oz.net [mailto:bokr at oz.net]
> > >
> > > ISTM the real question is if you could get a compile-time way
> > > of adjusting
> > > the string that is indented on the source, so as not be
> > > indented in its definition.
> >
> > Why add syntax? The easiest way to do this would be with a 
> __metaclass__
> ...
> > which has the advantage that you can do it Right Now.
> >
> Unfortunately there would appear to be no way to persuade the 
> compiler to
> use that metaclass when compiling string literals, so its use would be
> syntactically less convenient.

Sorry - not sure I understand here. My response was specifically for the
case of 'wanting the docstring to be stored in an already-"fixed" manner'.
This should be easy to do with a metaclass: when the class is constructed,
go through, retrieve all the docstrings (you could even use inspect.getdoc
;) and then assign them to the appropriate __doc__.

I could actually see this eventually being proposed to be default behaviour
for docstrings.

It of course wouldn't work for anything which was not a docstring.

I may just try coding this up and seeing if it works ;)

Tim Delaney

More information about the Python-list mailing list