2

I'm implementing a search algorithm (let's call it MyAlg) in a python package. Since the algorithm is super-duper complicated, the package has to contain an auxiliary class for algorithm options. Currently I'm developing the entire package by myself (and I'm not a programmer), however I expect 1-2 programmers to join the project later. This would be my first project that will involve external programmers. Thus, in order to make their lifes easier, how should I name this class: Options, OptionsMyAlg, MyAlgOptions or anything else?

What would you suggest me to read in this topic except for http://www.joelonsoftware.com/articles/Wrong.html ?

Thank you Yuri [cross posted from here: http://discuss.joelonsoftware.com/default.asp?design.4.684669.0 will update the answers in both places]

3 Answers 3

9

I suggest you read PEP8 (styleguide for Python code).

2

Just naming it Options should be fine. The Python standard library generally takes the philosophy that namespaces make it easy and manageable for different packages to have identically named things. For example, open is both a builtin and a function in the os module, several different modules define an Error exception class, and so on.

This is why it's generally considered bad form to say from some_module import * since it makes it unclear to which open your code refers, etc.

2

If it all fits in one file, name the class Options. Then your users can write:

import myalg

searchOpts = myalg.Options()
searchOpts.whatever()

mySearcher = myalg.SearchAlg(searchOpts)
mySearcher.search("where's waldo?")

Note the Python Style Guide referenced in another answer suggests that packages should be named with all lowercase letters.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.