Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.unix.shell,comp.unix.programmer,comp.lang.misc Subject: Re: Python (was Re: I did not inhale) Date: Fri, 30 Aug 2024 21:37:09 -0700 Organization: None to speak of Lines: 44 Message-ID: <87ttf148ay.fsf@nosuchdomain.example.com> References: <20240826083330.00004760@gmail.com> <20240826155113.000005ba@gmail.com> <87y14hd4bk.fsf@nosuchdomain.example.com> <87ikvlcs7i.fsf@nosuchdomain.example.com> <87ttf4bdcx.fsf@nosuchdomain.example.com> <875xrkb2iq.fsf@nosuchdomain.example.com> <87seuo9ikl.fsf@nosuchdomain.example.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Sat, 31 Aug 2024 06:37:12 +0200 (CEST) Injection-Info: dont-email.me; posting-host="78f6e35217d9802ff674987bcdbe52ec"; logging-data="931453"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+80/evwMXGCGu0YsUIdScA" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:yBaTVxgHwJ+Ghbxqb9s+RTmtrS0= sha1:o03aDOVQ+rhJQ2m3QxNiKUL9Zig= Bytes: 3534 Lawrence D'Oliveiro writes: > On Wed, 28 Aug 2024 19:19:38 -0700, Keith Thompson wrote: >> My impression is that your unconventional style indicates a relative >> lack of experience in Python. > > You think maybe I should practise by writing more Python code? And you snipped the part where I acknowledged that might be an invalid conclusion. I have no opinion on what you should do. > OK, how about your thoughts on comparing this > > for attrname in obj.tag_attrs : > attr = getattr(obj, attrname) > if attr != None : > if isinstance(attr, enum.Enum) : > attr = attr.value > elif isinstance(attr, Type) : > attr = unparse_signature(attr) > elif not isinstance(attr, str) : > raise TypeError("unexpected attribute type %s for %s" % (type(attr).__name__, repr(attr))) > attrs.append("%s=%s" % (attrname, quote_xml_attr(attr))) > out.write(" " * indent + "<" + tag_name) > > with this > > for attrname in obj.tag_attrs : > attr = getattr(obj, attrname) > if attr != None : > if isinstance(attr, enum.Enum) : > attr = attr.value > elif isinstance(attr, Type) : > attr = unparse_signature(attr) > elif not isinstance(attr, str) : > raise TypeError("unexpected attribute type %s for %s" % (type(attr).__name__, repr(attr))) > attrs.append("%s=%s" % (attrname, quote_xml_attr(attr))) > out.write(" " * indent + "<" + tag_name) The difference is obvious: the second calls attrs.append() even if attr is None. I don't know what point you're trying to make. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */