<br><br><div class="gmail_quote">On Wed, Jul 29, 2009 at 1:29 AM, David <span dir="ltr"><<a href="mailto:ldl08@gmx.net">ldl08@gmx.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Dear Tutors,<br>
<br>
whenever I make use of the help() function, I have a good chance of<br>
getting an error. I have not yet understood this tool very well.<br>
<br>
Take the modules operator and random as examples. The former is<br>
built-in, the latter not.<br>
Do I wish to see the help files, I have to use a different syntax:<br>
<br>
help(random)<br>
help('operator')<br>
<br>
I figured this by trial and error, and I am keen to find out when the<br>
help() function is to be supplied with a string, and when no '' is<br>
required. It certainly does not seem intuitive to me!</blockquote></div><br>>>> operator<br>Traceback (most recent call last):<br> File "<stdin>", line 1, in <module><br>NameError: name 'operator' is not defined<br>
>>> help('operator')<br><br>>>> random<br>Traceback (most recent call last):<br> File "<stdin>", line 1, in <module><br>NameError: name 'random' is not defined<br>
>>> help(random)<br>
Traceback (most recent call last):<br> File "<stdin>", line 1, in <module><br>NameError: name 'random' is not defined<br>>>> help('random')<br>(produces the helpfile)<br><br clear="all">
This goes back to pythons objects. If something is an object in python, you can probably pass it to help(), otherwise you need to pass a string.<br><br>>>> operator = 'foo'<br>>>> help(operator)<br>
Welcome to ASCII Assassin!<br> (1) Start Game<br> (2) Instructions<br><br>:> <br><br>I guess that's an easter egg... so I'm off to play ASCII Assassin!<br><br>HTH,<br>
Wayne<br>
<br>-- <br>To be considered stupid and to be told so is more painful than being called gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness, every vice, has found its defenders, its rhetoric, its ennoblement and exaltation, but stupidity hasn’t. - Primo Levi<br>