April 24th, 2005, 01:30 AM
Simple question about modules in documentation
Preface: I am still very virgin to Python.
Question: When browsing the Python online documentation I have found a ton of very useful info on modules however I am unsure if I am using them correctly. For instance the AskPassword function in the EasyDialogs module. The website says to use the function like so:
Do I need to "quote" the text that I enter?:
AskPassword(prompt[, default[, id[, ok[, cancel]]]])
I am confused as to what I am supposed to do, to quote or not to quote
AskPassword("What is the Password"[, "enter your pass here"[, id[, "proceed"[, "quit"]]]])
Also, what is the inside of the parenthesis. Do I simply specify an integer for my own use? Does the id have a significant importance?
Thanks A Lot
April 24th, 2005, 02:13 AM
Any variable inside  means an optional argument
so the least requirement is AskPassword(prompt)
and you can extend it by AskPassword(prompt, default) or using keywords AskPassword(prompt,id=intVar)
Comments on this post
April 24th, 2005, 07:09 AM
Thanks. I have a better understanding for the contents now. I am still fuzzy on the quoting though. Should I quote everything or not ? (please excuse my ignorance)
April 24th, 2005, 07:55 AM
If you pass is a string you quote it since it is a string
April 25th, 2005, 02:13 PM
To continue as monkey left of, yes you should quote you're strings. This is because of the way that Python and by convention most (if not all) modern languages chose to denote strings. For this you can use either double or single quotes in pairs or sets of three .
Notice the special use of the second set of strings, this is a multi-line string in Python. Meaning that the string can span more than one line . This is also how doc-strings are represented in Python i.e.
>>> "a String"
>>> 'a String'
... a String
... a String
This might seem a little confusing at first but it's really very simple: a doc string just ads another way to document your code. Pythons help() function also relies heavily on doc-strings.
>>> import random
>>> print random.__doc__
Random variable generators.
uniform within range
pick random element
pick random sample
generate random permutation
distributions on the real line:
distributions on the circle (angles 0 to 2pi)
General notes on the underlying Mersenne Twister core generator:
* The period is 2**19937-1.
* It is one of the most extensively tested generators in existence
* Without a direct way to compute N steps forward, the
semantics of jumpahead(n) are weakened to simply jump
to another distant state and rely on the large period
to avoid overlapping sequences.
* The random() method is implemented in C, executes in
a single Python step, and is, therefore, threadsafe.
If for example you wanted to look at the internal documentation for the str() class you could do something like this:
Hope this helps,
April 25th, 2005, 06:31 PM