Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.032 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'initialize': 0.07; 'received:192.168.178': 0.07; 'cookie': 0.09; 'andreas': 0.16; 'bye,': 0.16; 'received:192.168.178.20': 0.16; 'subject:fails': 0.16; 'subject:when': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'header :User-Agent:1': 0.23; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'url:python': 0.33; 'received:google.com': 0.35; 'url:org': 0.36; 'skip:o 20': 0.38; 'message-id:@gmail.com': 0.38; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'url:3': 0.61; 'url:http': 0.64; '8bit%:100': 0.72; 'subject:get': 0.81; 'explanation:': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=wfTX7qn7XuZmYV1ptjXCD/jI0IodSYVeE+Oz84gMW9o=; b=xgSKbrqDuphWWVACbKYQ6OSgCtdjep8HkAI81/IIRmXm2tmEKCygAeI1oHjVmpIOsB pcm78jLJyy7Nj8mvTJs7Mnot8AeVszx1IKmeYM+lgmBuX3cpC/UVeWk94NEgJNj0TC0H L8UxS7L0+g/UPIzMotG3zAldDjFCg6Eq1d2AuuUFg1b8UvRsEyzWQmxCuCe4L1d4ykb7 ISCt7zDb0OeY9Q4ZfhVpkJLbrMk8wT5nidy01DgU1JGf8yQiek0UFaCn7Ej3m0KbHBhF DAmisQ2rVmd8l7KGS8QKJ3iorl//6G5g5CEqLwdKlD1Y4gwok7LuyzpP6SwfKs+HClYW WocQ== X-Received: by 10.205.65.17 with SMTP id xk17mr18317678bkb.19.1380992203385; Sat, 05 Oct 2013 09:56:43 -0700 (PDT) Date: Sat, 05 Oct 2013 18:56:41 +0200 From: Andreas Perstinger User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Select fails when cookie tried to get a numeric value References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 33 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1380992210 news.xs4all.nl 15894 [2001:888:2000:d::a6]:39950 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:56210 On 05.10.2013 16:24, Νίκος Αλεξόπουλος wrote: > # initialize cookie > cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') ) > cookie.load( cookie ) Watch: >>> cookie1 = cookies.SimpleCookie('ID=42') >>> cookie1.load(cookie1) >>> print(cookie1) Set-Cookie: ID="Set-Cookie: ID=42" >>> cookie1.get('ID').value 'Set-Cookie: ID=42' And now watch this: >>> cookie2 = cookies.SimpleCookie('ID=42') >>> print(cookie2) Set-Cookie: ID=42 >>> cookie2.get('ID').value '42' Explanation: http://docs.python.org/3/library/http.cookies.html#http.cookies.BaseCookie.load >>> c = cookies.SimpleCookie('ID=42') >>> isinstance(c, dict) True >>> c.items() dict_items([('ID', )]) Bye, Andreas