title: String options for function input python
body: <p>I am writing a Python function (2.7) where one of the input parameters is a string. The string value should be one of a few values. </p>
  
  <p>i.e. the parameter, in this case "sort" could be any from the list ['first author' 'last author' 'title'] ( the list is actually a bit longer)</p>
  
  <p>Is there a nice way of helping the user supply this input (via tab completion). The ultimate goal is to try and improve the interface for the user so that it is easier for them to use my code and to make less mistakes.</p>
  
  <p><strong>Option 1: Define constants</strong></p>
  
  <p>This might be the best option but there are multiple ways of doing this. My approach is below.</p>
  
  <p>I'm considering creating constants in the module in which the function resides, but this seems messy. My current solution is to include a class with the options, but this makes the input really long, unless I cheat and make the class something nonsensical and short (which is what I've done but it seems wrong and non-obvious). What should I do? </p>
  
  <p><strong>Option 2: Via interpreted documentation</strong></p>
  
  <p>NOTE: I don't think this option actually exists ...</p>
  
  <p>I like the idea of placing code in the documentation which editors could use to perform tab-complete, but I'm not aware of this option existing.</p>
  
  <p><strong>Other options?</strong></p>
  
  <p>Current code (roughly):</p>
  
  <pre><code>class C(): 
      SORT_FIRST_AUTHOR = 'first author'
      SORT_LAST_AUTHOR  = 'last author'
      SORT_TITLE        = 'title'
  
   #Ideally these might be selected by: my_module.search.sort_option.FIRST_AUTHOR instead of my_module.C.FIRST_AUTHOR but that's REALLY long
  
  
  def search(query_string,sort = None): #Changed sort = [], to sort = None per comments
  </code></pre>
  
  <p>UPDATE: (Trying to clarify the question)</p>
  
  <p>This is somewhat similar to this question, although I think the answers diverge from what I'm looking for because of the specifics of the question.</p>
  
  <p><a href="https://stackoverflow.com/questions/9522877/pythonic-way-to-have-a-choice-of-2-3-options-as-an-argument-to-a-function">Pythonic way to have a choice of 2-3 options as an argument to a function</a></p>
  
  <p>Ideally, I would like the definition of search() to allow tab completion on "sort" by having specifications, something like:</p>
  
  <pre><code>def search(....):
     """
     :param sort:
     :values sort: 'first author'|'last author'|'title'
     """
  </code></pre>
  
  <p>But, I'm not aware of that actually being a valid documentation option.</p>
  
  <p>alternatively, I could define some constants that allows this so that the call becomes:</p>
  
  <p>search(my_a,my_b,package_name.C.SORT_FIRST_AUTHOR)</p>
  
  <p>But this seems ugly and wrong.</p>
  
  <p>So when you want the user to pass in one out of a set of options, how do you do it?</p>