Deutsch   English   Français   Italiano  
<utumm9$1s41o$2@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: DFS <nospam@dfs.com>
Newsgroups: comp.os.linux.advocacy
Subject: Re: Tabs As Syntax
Date: Tue, 26 Mar 2024 10:39:07 -0400
Organization: A noiseless patient Spider
Lines: 55
Message-ID: <utumm9$1s41o$2@dont-email.me>
References: <17be73f7d87a06e9$246570$4075406$802601b3@news.usenetexpress.com>
 <utejt0$1fq95$1@dont-email.me> <utfstp$1pfg9$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 26 Mar 2024 15:39:05 +0100 (CET)
Injection-Info: dont-email.me; posting-host="31d28351982304b8d57cb7a4ee4f1c04";
	logging-data="1970232"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/C80s6drY0+irErCvHGvzv"
User-Agent: Betterbird (Windows)
Cancel-Lock: sha1:NFZMMv2s7TEnVNkltDRMpoNPFmE=
Content-Language: en-US
In-Reply-To: <utfstp$1pfg9$2@dont-email.me>
Bytes: 3150

On 3/20/2024 7:53 PM, Lawrence D'Oliveiro wrote:


> Python does away with that redundancy, by making the indentation serve
> as statement-bracketing as well. I think this is a mistake. However, I
> restore the redundancy by adding “#end” lines (which the compiler
> ignores). E.g.
> 
>      def parse_headers() :
>          nonlocal content_type, content_type_opts
>          for keyword, value in scope["headers"] :
>              keyword = keyword.decode().lower()
>              if keyword == "content-type" :
>                  content_type = value.decode()
>              elif keyword == "cookie" :
>                  for item in value.decode().split(";") :
>                      name, val = item.strip().replace(" ", "").split("=", 1)
>                      cookies[name] = val
>                  #end for
>              #end if
>          #end for
>          if content_type != None :
>              content_type, content_type_opts = \
>                  multipart.multipart.parse_options_header(content_type)
>              content_type = content_type.decode()
>              content_type_opts = dict((k.decode(), v) for k, v in content_type_opts.items())
>          #end if
>      #end parse_headers




Let me fix that back for you:

  def parse_headers() :
         nonlocal content_type, content_type_opts
         for keyword, value in scope["headers"] :
             keyword = keyword.decode().lower()
             if keyword == "content-type" :
                 content_type = value.decode()
             elif keyword == "cookie" :
                 for item in value.decode().split(";") :
                     name, val = item.strip().replace(" ", "").split("=", 1)
                     cookies[name] = val
         if content_type != None :
             content_type, content_type_opts = \
                 multipart.multipart.parse_options_header(content_type)
             content_type = content_type.decode()
             content_type_opts = dict((k.decode(), v) for k, v in 
content_type_opts.items())


much better