Re: Markov Analysis Help

Discussion in 'Python' started by bearophileHUGS@lycos.com, May 17, 2008.

  1. Guest

    dave, few general comments to your code:
    - Instead of using a comment that explains the meaning of a function,
    add such things into docstrings.
    - Your names can be improved, instead of f you can use file_name or
    something like that, instead of convert_file you can use a name that
    denotes that the conversion is already done, etc.
    - You can use xrange instead of range and you can indent less, like 4
    spaces.
    - This line may be slow, you may want to find simpler ways to do the
    same thing:
    rkey = random.choice(analyze.keys())
    - I suggest you to add doctests to all your functions.

    Bye,
    bearophile
    , May 17, 2008
    #1
    1. Advertising

  2. Terry Reedy Guest

    "dave" <> wrote in message
    news:g0mvc2$sic$...
    | bear,
    | thanks for the suggestions. I use IDLE to write the code and when it's
    | working I paste it over into a new window.

    Or you can just save code you want to keep to a new name.

    | To add doctests would I need to use a certain
    | filename for the tests to be run on?

    You can run a doctest on a file from within the file (as well as from
    without).

    if __name__ == '__main__': <run doctest>

    I presume the manual gives the details.

    | Can you have doctests on random functions?

    ???

    tjr
    Terry Reedy, May 17, 2008
    #2
    1. Advertising

  3. Guest

    dave:
    >Can you have doctests on random functions?


    Yes, you can add doctests to methods, functions, classes, module
    docstrings, and in external text files.

    Bye,
    bearophile
    , May 17, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    7
    Views:
    522
  2. kpp9c

    markov query

    kpp9c, Mar 14, 2006, in forum: Python
    Replies:
    5
    Views:
    479
    Robert Kern
    Mar 15, 2006
  3. kpp9c
    Replies:
    8
    Views:
    302
    Max M
    Mar 16, 2006
  4. Replies:
    0
    Views:
    100
  5. vsv
    Replies:
    1
    Views:
    106
    Dave Burt
    Apr 11, 2006
Loading...

Share This Page