[Tutor] Suggestions about documenting a function

Jorge Azedo jazedo at netcabo.pt
Tue Oct 31 02:29:25 CET 2006

I'm writing a function that generates a list with user defined length, 
that consists only of non-repeating random integers in a user defined range.
Even I don't understand what I just wrote, so I'm just going to post the 
code and an example of the results :P

## Test module
## Last revision 31 October 2006

import random

def randomList(n1,n2,len):
    '''n1-n2 range of numbers, len - length of the final list

    Returns a list'''

    if len > n2:
        return 'The length of the list must be greater than n2'
        while i < len:
            if rndlist.count(rand) == 0:
    return rndlist

[9, 8, 1, 4, 7, 6, 5, 3, 2]

Not sure if the indentation in this message is correct, but the module 
works, so that's not the problem. What I really want to ask is: Any 
suggestions on how to improve the documentation part of the module? I'd 
like to warn the user about the fact that len must be greater than n2 
before he runs it, but I can't think of a short enough way to say it so 
that it still appears in that little window that shows up when  you 
start writing the arguments to a function.
Sorry if this is confusing

More information about the Tutor mailing list