Trying to set a cookie within a python script

Νίκος nikos.the.gr33k at gmail.com
Tue Aug 3 15:24:44 CEST 2010


> On 3 Αύγ, 11:10, Dave Angel <da... at ieee.org> wrote:

> a) a text editor takes keystrokes and cut/paste info and other data, and
> produces a stream of (unicode) characters.  It then encodes each of  
> those character into one or more bytes and saves it to a file.  You have
> to tell Notepad++ how to do that encoding.  Note that unless it's saving
> a BOM, there's no clue in the file what encoding it used.

So actually when i'm selecting an encoding from Notepad++'s options
iam basically telling the editor the way the it's suppose to store
those streams of characters to the hard disk drive.

Different encodings equals different ways of storting the data to the
media, correct?


> b) The python compiler has to interpret the bytes it finds (spec. within
> string literals and comments), and decode them into unicode for its own
> work.  It uses the 'coding:' comment to decide how to do this.  But once
> the file has been compiled, that comment is totally irrelevant, and ignored.

What is a "String Literal" ?

Basically if i understood you right, this line of code tells Python
the opposite thign from (a).
(a) told the editor how to store data to the media, while (b) tells
the python compiler how to retrive these data from the media(how to
read it, that is!) Right?


> c1) Your python code has to decide how to encode its information when
> writing to stdout.  There are several ways to accomplish that.

what other ways except the prin '''Content-Type blah blah... ''' ?


> c2) The browser sees only what was sent to stdout, starting with the
> "Content-Type..." line.  It uses that line to decide how to decode the
> rest of the stream.  Let me reemphasize, the browser does not see any of
> the python code, or comments.

I was under the impression the the stdout of a cgi python script was
the web server itself since this is the one app that awaits for the
data to be displayed.

When a python script runs it produces html output that time or only
after the
python's output to the Web Server the html output is produced?


And something else please.
My cgi python scripts contains english and greek letters, hence this
is an indication of tellign the editor to save the file to disk as
utf-8 right?

Well i told Notepad++ to save ti as Ascii and also removed the '# -*-
coding: utf-8 -*-' line.

and only used print ''' Content-Type: text/html; charset=UTF-8 /n'''

So, how the editor managed to save the file as ascii although my file
coaniens characters that are beyond the usual 7-bit ascci set?

and how could the python compiler 'read them and executed them' ?

I shoulds have saved in utf-8 and have inside the script the line so
the compiler knew to open it as utf-8. How come it dit work as ascii
both in stroing and retreiving!!






More information about the Python-list mailing list