Reputation: 18122
I would like to do something like this :
def main():
"""
Display Information about a Google Calendar
-u --user login Google Login
-p --pass password Google Password
-d --debug Set DEBUG = True
-h --help Display this help
"""
print(__doc__)
if __name__ == "__main__":
main()
But the answer is : None
... Why ?
Upvotes: 0
Views: 980
Reputation: 94575
If the help that you want to print is "global", you might find it more logical to put it as the main documentation for your program:
#!/usr/bin/env python
"""
Display Information about a Google Calendar
...
"""
if __name__ == '__main__':
print __doc__
__doc__
is a global variable that contains the documentation string of your script.
Upvotes: 2
Reputation: 20486
Because __doc__
is an attribute of the function, not a local variable. You need to refer to it as main.__doc__
like this:
def main():
"""Display Information about a Google Calendar
..."""
print(main.__doc__)
if __name__ == "__main__":
main()
Upvotes: 4