title: Pythonic way to Validate time input (only for Hr, Min, Sec)
body: <p>In my application,I am getting time input in a variable in string format e.g. <code>Values = '12,12,12'</code>.  </p>
  
  <p>Now i need to validate it <code>h&lt;24 M&lt;60 S&lt;60</code> etc. and  i want final output in <code>'%H:%M:%S'</code> format.<br>
  To get this i tried <code>datetime.time().</code></p>
  
  <p>I had 1st tried with <code>values = '12'</code> then <code>'12,12,12'</code>.</p>
  
  <pre><code>In [1]: import datetime
  
  In [2]: values = '12'
  
  In [3]: d = datetime.time(values)
  
  TypeError  Traceback (most recent call last)
  /mypc/test/&lt;ipython console&gt; in &lt;module&gt;()
  TypeError: an integer is required
  
  In [4]: d = datetime.time(int(values))
  
  In [5]: d
  Out[5]: datetime.time(12, 0)
  
  In [6]: d.strftime('%H:%M:%S')
  Out[6]: '12:00:00'
  
  In [7]: s = d.strftime('%H:%M:%S')
  
  In [8]: s
  Out[8]: '12:00:00'
  
  In [9]: values = '12,12,12'
  
  In [10]: d = datetime.time(int(values))
  
  ValueError: invalid literal for int() with base 10: '12,12,12'
  </code></pre>
  
  <p>But it works as below.</p>
  
  <pre><code>In [24]: datetime.time(12,12,12).strftime('%H:%M:%S')
  Out[24]: '12:12:12'
  </code></pre>
  
  <p>So problem is that datetime.time() is taking input as integer and <code>'12,12,12'</code> string cannot be converted in int.</p>
  
  <p>Is there any other way(otherthan regexp) to do the validation for only Hr:M:S.</p>