title: Learning Python, is there a better way to write this?
body: <p>I am learning Python (2.7) and to test what I have learned so far I wrote a temperature converter that converts Celsius to Fahrenheit and I wanted to know if my code could be written better to be faster or something more Pythonic. And could someone tell me if there is an actual name for the <code>if __name__ == '__main__': main()</code> (out of curiosity)?</p>
  
  <pre><code>from sys import argv, exit # import argv and exit functions
  
  def to_f(c): # Convert celsius to ferinheight
      temp = (c * 9/5) + 32
      return temp
  
  def to_c(f): # Convert ferinheight to celsius
      temp = (f - 32) * 5/9
      return temp
  
  def main():
      args = argv[1:] # Creates an argument list omitting the omitting the [0] element
      if len(argv) &lt; 2: exit(1) # If less than two arguments
      if args[0] == '-f': # If the first argument is -f
          print args[1], 'ferinheight is', str(to_c(int(args[1]))), 'celsius'
      elif args[0] == '-c': # If the first argument is -c
          print args[1], 'celsius is', str(to_f(int(args[1]))), 'ferinheight'
      else: exit(1)
  
  if __name__ == '__main__':
      main()
  </code></pre>
  
  <p><a href="http://pastebin.com/rjeNikDt" rel="nofollow noreferrer" title="http://pastebin.com/rjeNikDt">http://pastebin.com/rjeNikDt</a></p>