title: Why type('string') seems to return null string in python cgi
body: <p>I'm reading Mark Lutz's <em>Programming Python 3rd editon</em> , and I'm puzzled with a question: <code>type('something')</code> always result in an empty string.</p>
  
  <p>Could someone kindly explain this?</p>
  
  <p>Context info:</p>
  
  <p>I add one line to the script <code>$CODEROOT\pp3e\Internet\Web\cgi-bin\tutor0.py</code> </p>
  
  <pre><code>#!/usr/bin/python
  #######################################################
  # runs on the server, prints html to create a new page;
  # url=http://localhost/cgi-bin/tutor0.py
  #######################################################
  
  print "Content-type: text/html\n"
  print "&lt;TITLE&gt;CGI 101&lt;/TITLE&gt;"
  print "&lt;H1&gt;A First CGI script&lt;/H1&gt;"
  print '&lt;p&gt;[%s]'%type('apple') # ★ I add this line
  print "&lt;P&gt;Hello, CGI World!&lt;/P&gt;"
  </code></pre>
  
  <p><strong>For the added line, I hope to see in browser <code>[&lt;type 'str'&gt;]</code> , but I actually see <code>[]</code> .</strong></p>
  
  <p><img src="https://i.stack.imgur.com/GfKzy.png" alt="enter image description here"></p>
  
  <p>The python to start a HTTP server is at <code>$CODEROOT\pp3e\Internet\Web\webserver.py</code></p>
  
  <pre><code>#########################################################################
  # implement HTTP web server in Python which knows how to serve HTML
  # pages and run server side CGI scripts;  serves files/scripts from
  # the current working dir and port 80, unless command-line args;
  # python scripts must be stored in webdir\cgi-bin or webdir\htbin;
  # more than one of these may be running on the same machine to serve
  # from different directories, as long as they listen on different ports;
  #########################################################################
  
  webdir = '.'   # where your html files and cgi-bin script directory live
  port   = 80    # http://servername/ if 80, else use http://servername:xxxx/
  
  import os, sys
  from BaseHTTPServer import HTTPServer
  from CGIHTTPServer  import CGIHTTPRequestHandler
  
  if len(sys.argv) &gt; 1: webdir = sys.argv[1]             # command-line args
  if len(sys.argv) &gt; 2: port   = int(sys.argv[2])        # else dafault ., 80
  print 'webdir "%s", port %s' % (webdir, port)
  
  # hack for Windows: os.environ not propogated
  # to subprocess by os.popen2, force in-process
  if sys.platform[:3] == 'win':
      CGIHTTPRequestHandler.have_popen2 = False
      CGIHTTPRequestHandler.have_popen3 = False          # emulate path after fork
      sys.path.append('cgi-bin')                         # else only adds my dir
  
  os.chdir(webdir)                                       # run in html root dir
  srvraddr = ("", port)                                  # my hostname, portnumber
  srvrobj  = HTTPServer(srvraddr, CGIHTTPRequestHandler)
  srvrobj.serve_forever()                                # serve clients till exit
  </code></pre>
  
  <p>My environment:</p>
  
  <ul>
  <li>Python 2.7</li>
  <li>Windows 7 x64</li>
  </ul>