Sujet : Re: Python (was Re: I did not inhale)
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : comp.unix.shell comp.unix.programmer comp.lang.miscDate : 31. Aug 2024, 00:52:12
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vatlvc$mhl0$3@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
User-Agent : Pan/0.160 (Toresk; )
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?
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)