pythoncgictypesctype

Are ctype and ctypes different in python?


I am learning python and am confused with ctype and ctypes. In the lecture, the instructor uses ctype and I searched it but only ctypes module result. So I am not sure ctype and ctypes are same in python. In official documentation, I have to import ctypes, however I didn't import it.

This my code,

from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
import cgi
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker

def do_POST(self):
        try:
            if self.path.endswith('/edit'):
                ctype, pdict = cgi.parse_header(
                    self.headers.getheader('content-type')
                )
                if ctype=='multipart/form-data':
                    fields = cgi.parse_multipart(self.rfile, pdict)
                    messagecontent = fields.get('newRestaurantName')
                    restaurantIDPath = self.path.split("/")[2]
                    myRestaurantQuery= session.query(Restaurant).filter_by(
                        if=restaurantIDPath).one()
                    if myRestaurantQuery!=[]:
                        myRestaurantQuery.name = messagecontent[0]
                        session.add(myRestaurantQuery)
                        session.commit()
                        self.send_response(301)
                        self.send_header('Content-type','text/html')
                        self.send_header('Location','/restaurants')
                        self.end_headers()

If they are different, what category should I have to look for comparing between two ? Thanks in advance!


Solution

  • The ctypes module is a way of interfacing with C (language) types while the ctype you are referring to in your question stands for content-type. See here https://docs.python.org/2/library/cgi.html