[omniORB] comments BEFORE or after decl, again
Tres Seaver
tseaver@palladion.com
Tue, 28 Mar 2000 09:25:47 -0600
Richard Gruet wrote:
<snip>
> Of course, all this assumes that the traversal order is correct (ie same as
> declaration order).
> This solution doesn't require any change in Duncan's code; I agree with him
> that creating specific nodes for comments whould raise many issues, and that
> some kind of policy is needed concerning the order of comments (but I do
> think that 90% people put their comments BEFORE, and Python doc convention is
> rather a curiosity!)
>
> Opinions ?
What perhaps is not clear to non-Pythonistas is that Python supports both
ignore-to-eol comments, prepended with "#" in the classic scripting language
tradition, and "docstrings", which are string literals, appearing immediately
following a class or function definition or as the first non-comment production
in a module.
Comments can appear anywhere, and "disappear" from the compiled bytecode, just
as C/C++/.... comments do. Docstrings remain in the bytecode, and are available
at runtime, bound to the __doc__ attribute of the preceding entity.
>>> def foo( bar, baz ):
... """Concatenate bar and baz as strings, in ascending order. """
... if baz < bar:
... return "%s %s" % ( baz, bar )
... else:
... return "%s %s" % ( bar, baz )
...
>>> print foo.__doc__
Concatenate bar and baz as strings, in ascending order.
--
=========================================================
Tres Seaver tseaver@digicool.com tseaver@palladion.com