<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jul 25, 2011, at 1:06 PM, Michael Foord wrote:</div><blockquote type="cite"><div class="gmail_quote"><div><font class="Apple-style-span" color="#000000"><br></font> Python standard library modules
currently using integers for constants:
<br>
<br>* re - has flags (OR'able constants) defined in sre_constants, each flag
has two names (e.g. re.IGNORECASE and re.I)
<br></div></div></blockquote><div><br></div><div>What is being proposed here? Will there be a new namespace so that we would start writing re.Flags.IGNORECASE instead of re.IGNORECASE? Are module level constants now going to be considered bad-form?</div><div><br></div><div>If constants switch from re.IGNORECASE to re.flags.IGNORECASE, are there any benefits to compensate for being both wordier and slower?</div><div><br></div><br><blockquote type="cite"><div class="gmail_quote"><div>* os has SEEK_SET, SEEK_CUR, SEEK_END - <b class="moz-txt-star"><span class="moz-txt-tag">*</span>plus<span class="moz-txt-tag">*</span></b> those implemented in
posix / nt
<br></div></div></blockquote><div><br></div><div>Ditto</div><br><blockquote type="cite"><div class="gmail_quote"><div>* doctest has its own flag system, but is really just using integer
flags / constants (quite a few of them)
<br>* token has a tonne of constants (autogenerated)
<br>* socket exports a bunch of constants defined in _socket
<br>* gzip has flags: FTEXT, FHCRC, FEXTRA, FNAME, FCOMMENT
<br>
<br>* errno (builtin module)
<br>
<br>EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET, EINVAL,
<br>ENOTCONN, ESHUTDOWN, EINTR, EISCONN, EBADF, ECONNABORTED
<br></div></div></blockquote><div><br></div>It seems to me that an enum module or class doesn't make any of this code better.</div><div>AFAICT enums are a fat solution to a thin problem.</div><div><br></div><div>Since python makes it so easy to put constants in class namespaces</div><div>and module namespaces, there is much less need for enums than in</div><div>statically compiled languages. I think the perceived need is really</div><div>more of a carry-over coding habit than an actual need. </div><div><br></div><div>That being said, this proposal seems to have momentum,</div><div>so it is going happen anyway. Once introduced, people will</div><div>think we've endorsed enums as the one right way to code</div><div>constants, so we will start to see them everywhere. </div><div>Expect enums to become ubiquitous.</div><div><div><br></div><div><br></div><div>Raymond</div></div></body></html>