summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorKa-Ping Yee <ping@zesty.ca>2001-01-18 07:50:17 (GMT)
committerKa-Ping Yee <ping@zesty.ca>2001-01-18 07:50:17 (GMT)
commit3a9582fbe53fb6302785dd0fa7d2eeb6f29477f6 (patch)
tree2a188d21ad20a7dff18aaa65ffdad12091163f80 /Doc
parent6f477a6c075311dff67d873792f9844bab09a38e (diff)
downloadcpython-3a9582fbe53fb6302785dd0fa7d2eeb6f29477f6.zip
cpython-3a9582fbe53fb6302785dd0fa7d2eeb6f29477f6.tar.gz
cpython-3a9582fbe53fb6302785dd0fa7d2eeb6f29477f6.tar.bz2
Fix the example (it didn't seem to reflect reality).
Diffstat (limited to 'Doc')
-rw-r--r--Doc/lib/libcookie.tex26
1 files changed, 14 insertions, 12 deletions
diff --git a/Doc/lib/libcookie.tex b/Doc/lib/libcookie.tex
index d9dcd8a..c76e123 100644
--- a/Doc/lib/libcookie.tex
+++ b/Doc/lib/libcookie.tex
@@ -173,19 +173,21 @@ The meaning for \var{attrs} is the same as in \method{output()}.
\subsection{Example \label{cookie-example}}
-The following example demonstrates how to open a can of spam using the
-\module{spam} module.
+The following example demonstrates how to use the \module{Cookie} module.
\begin{verbatim}
>>> import Cookie
>>> C = Cookie.SimpleCookie()
>>> C = Cookie.SerialCookie()
>>> C = Cookie.SmartCookie()
->>> C = Cookie.Cookie() # backwards compatible alias for SmartCookie
+>>> C = Cookie.Cookie() # backwards-compatible alias for SmartCookie
>>> C = Cookie.SmartCookie()
>>> C["fig"] = "newton"
>>> C["sugar"] = "wafer"
->>> C # generate HTTP headers
+>>> print C # generate HTTP headers
+Set-Cookie: sugar=wafer;
+Set-Cookie: fig=newton;
+>>> print C.output() # same thing
Set-Cookie: sugar=wafer;
Set-Cookie: fig=newton;
>>> C = Cookie.SmartCookie()
@@ -197,18 +199,18 @@ Cookie: rocky=road; Path=/cookie;
Cookie: rocky=road;
>>> C = Cookie.SmartCookie()
>>> C.load("chips=ahoy; vienna=finger") # load from a string (HTTP header)
->>> C
+>>> print C
Set-Cookie: vienna=finger;
Set-Cookie: chips=ahoy;
>>> C = Cookie.SmartCookie()
->>> C.load('keebler="E=everybody; L=\"Loves\"; fudge=\012;";')
->>> C
+>>> C.load('keebler="E=everybody; L=\\"Loves\\"; fudge=\\012;";')
+>>> print C
Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=\012;";
>>> C = Cookie.SmartCookie()
>>> C["oreo"] = "doublestuff"
>>> C["oreo"]["path"] = "/"
->>> C
-Set-Cookie: oreo="doublestuff"; Path=/;
+>>> print C
+Set-Cookie: oreo=doublestuff; Path=/;
>>> C = Cookie.SmartCookie()
>>> C["twix"] = "none for you"
>>> C["twix"].value
@@ -220,7 +222,7 @@ Set-Cookie: oreo="doublestuff"; Path=/;
'7'
>>> C["string"].value
'seven'
->>> C
+>>> print C
Set-Cookie: number=7;
Set-Cookie: string=seven;
>>> C = Cookie.SerialCookie()
@@ -230,7 +232,7 @@ Set-Cookie: string=seven;
7
>>> C["string"].value
'seven'
->>> C
+>>> print C
Set-Cookie: number="I7\012.";
Set-Cookie: string="S'seven'\012p1\012.";
>>> C = Cookie.SmartCookie()
@@ -240,7 +242,7 @@ Set-Cookie: string="S'seven'\012p1\012.";
7
>>> C["string"].value
'seven'
->>> C
+>>> print C
Set-Cookie: number="I7\012.";
Set-Cookie: string=seven;
\end{verbatim}