[Pythonmac-SIG] silly variable evaluation question
Joseph J. Strout
joe@strout.net
Sat, 27 Nov 1999 12:55:56 -0800
At 12:39 PM -0800 11/27/99, Dante wrote:
>That seems pretty extravagant, is that really the only way to do
>this?
It's not extravagant, it's just embellished compared to your version, with
niceties like error trapping, looping over all contents of the module,
printing a header for each one, etc. The correct equivalent of what you
wrote is simply:
import Res
foo = dir(Res)[0]
print foo.__doc__
I.e., the only mistake you made is trying to write "Res.foo" -- as you
noted, foo isn't defined in Res. It's defined in the current module (where
the code above lives); the fact that it *refers* to something in another
module doesn't matter. It's "foo" regardless of what it refers too, not
"Res.foo" just because it happens to refer to something in "Res".
>Where is the % behavior being exhibited in this documented?
It's a string operator, and documented in the library reference under "More
String Operations"
(http://www.python.org/doc/current/lib/typesseq-strings.html).
>The python documentation appears to be lengthy but organized extremely
>poorly.
I think this is unfair -- I have always found it to be very easy to find
what I'm looking for. Perhaps it just requires a few moments to
familiarize yourself with it.
Cheers,
-- Joe
P.S. The python-tutor mailing list might be better suited for questions
like these.
,------------------------------------------------------------------.
| Joseph J. Strout Biocomputing -- The Salk Institute |
| joe@strout.net http://www.strout.net |
`------------------------------------------------------------------'