#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2005
    Posts
    28
    Rep Power
    0

    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:
    Code:
    AskPassword(prompt[, default[, id[, ok[, cancel]]]])
    Do I need to "quote" the text that I enter?:
    Code:
    AskPassword("What is the Password"[, "enter your pass here"[, id[, "proceed"[, "quit"]]]])
    I am confused as to what I am supposed to do, to quote or not to quote

    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
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2004
    Posts
    73
    Rep Power
    11
    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

    • monkeyman23555 agrees : I agree
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2005
    Posts
    28
    Rep Power
    0
    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)
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2004
    Location
    There where the rabbits jump
    Posts
    556
    Rep Power
    12
    If you pass is a string you quote it since it is a string
  8. #5
  9. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    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 .

    Code:
    >>> "a String"
    'a String'
    >>> 'a String'
    'a String'
    >>> """
    ... a String
    ... """
    '\na String\n'
    >>> '''
    ... a String
    ... '''
    '\na String\n'
    >>>
    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.

    Code:
    >>> import random
    >>> print random.__doc__
    Random variable generators.
    
        integers
        --------
               uniform within range
    
        sequences
        ---------
               pick random element
               pick random sample
               generate random permutation
    
        distributions on the real line:
        ------------------------------
               uniform
               normal (Gaussian)
               lognormal
               negative exponential
               gamma
               beta
               pareto
               Weibull
    
        distributions on the circle (angles 0 to 2pi)
        ---------------------------------------------
               circular uniform
               von Mises
    
    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.
    
    
    >>>
    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.

    If for example you wanted to look at the internal documentation for the str() class you could do something like this:

    Code:
    >>> help(str)
    ...
    Hope this helps,

    Mark.
    programming language development: www.netytan.com Hula

  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2005
    Posts
    28
    Rep Power
    0
    Thanks A Ton!

IMN logo majestic logo threadwatch logo seochat tools logo