[PEP 224] Attribute Docstrings
Warren Focke
wfocke at phoenixdsl.com
Fri Aug 25 19:37:04 EDT 2000
Marc-Andre Lemburg:
> This can lead to cases where the docstring and assignment may be
> separated by other expressions:
>
> class C:
> "C doc string"
>
> b = 2
>
> def x(self):
> "C.x doc string"
> y = 3
> return 1
>
> "b's doc string"
>
> Since the definition of method "x" currently does not reset the
> used assignment name variable, it is still valid when the compiler
> reaches the docstring "b's doc string" and thus assigns the string
> to __doc__b__.
>
> A possible solution to this problem would be resetting the name
> variable for all non-expression nodes.
So under the "possible solution", the above code would produce
C.x.__doc__ == "C.x doc string"
C.__doc__x__ == "b's doc string"
and C.x would then have two doc strings? Would it be reasonable to only
reset the variable if x didn't have a .__doc__?
Warren Focke
--
Just because romance and rapture have so often served as a pretext for
curdled banality doesn't make the sentiments themselves obsolete.
-- Michelle Goldberg
More information about the Python-list
mailing list