Sujet : Re: Tabs As Syntax
De : nospam (at) *nospam* dfs.com (DFS)
Groupes : comp.os.linux.advocacyDate : 26. Mar 2024, 16:39:07
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <utumm9$1s41o$2@dont-email.me>
References : 1 2 3
User-Agent : Betterbird (Windows)
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