Velocity Reviews

Velocity Reviews (
-   Python (
-   -   Re: Markov Analysis Help ( 05-17-2008 12:01 PM

Re: Markov Analysis Help
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
- 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.


Terry Reedy 05-17-2008 04:13 PM

Re: Markov Analysis Help

"dave" <> wrote in message
| 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

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

I presume the manual gives the details.

| Can you have doctests on random functions?


tjr 05-17-2008 08:05 PM

Re: Markov Analysis Help
>Can you have doctests on random functions?

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


All times are GMT. The time now is 08:28 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.