<div dir="ltr"><span style="color:rgb(54,57,61);font-family:"MS JhengHei","MS PGothic",sans-serif;font-size:15px;background-color:rgb(236,238,243);text-decoration-style:initial;text-decoration-color:initial;display:inline;float:none">Dear Sanyam,Mariatta and Steve,<span> </span></span><br style="color:rgb(54,57,61);font-family:"MS JhengHei","MS PGothic",sans-serif;font-size:15px;background-color:rgb(236,238,243);text-decoration-style:initial;text-decoration-color:initial"><span style="color:rgb(54,57,61);font-family:"MS JhengHei","MS PGothic",sans-serif;font-size:15px;background-color:rgb(236,238,243);text-decoration-style:initial;text-decoration-color:initial;display:inline;float:none">Thanks for your feedback.<span> </span></span><br style="color:rgb(54,57,61);font-family:"MS JhengHei","MS PGothic",sans-serif;font-size:15px;background-color:rgb(236,238,243);text-decoration-style:initial;text-decoration-color:initial"><span style="color:rgb(54,57,61);font-family:"MS JhengHei","MS PGothic",sans-serif;font-size:15px;background-color:rgb(236,238,243);text-decoration-style:initial;text-decoration-color:initial;display:inline;float:none">I will read<span> </span></span><a href="https://devguide.python.org/" class="gmail-" target="_blank" style="text-decoration:underline;color:rgb(9,140,224);word-break:break-all;font-family:"MS JhengHei","MS PGothic",sans-serif;font-size:15px;background-color:rgb(236,238,243)">https://devguide.python.org/</a><span style="color:rgb(54,57,61);font-family:"MS JhengHei","MS PGothic",sans-serif;font-size:15px;background-color:rgb(236,238,243);text-decoration-style:initial;text-decoration-color:initial;display:inline;float:none"><span> </span>carefully.<span> </span></span><br style="color:rgb(54,57,61);font-family:"MS JhengHei","MS PGothic",sans-serif;font-size:15px;background-color:rgb(236,238,243);text-decoration-style:initial;text-decoration-color:initial"><span style="color:rgb(54,57,61);font-family:"MS JhengHei","MS PGothic",sans-serif;font-size:15px;background-color:rgb(236,238,243);text-decoration-style:initial;text-decoration-color:initial;display:inline;float:none">Best regards,<span> </span></span><br style="color:rgb(54,57,61);font-family:"MS JhengHei","MS PGothic",sans-serif;font-size:15px;background-color:rgb(236,238,243);text-decoration-style:initial;text-decoration-color:initial"><span style="color:rgb(54,57,61);font-family:"MS JhengHei","MS PGothic",sans-serif;font-size:15px;background-color:rgb(236,238,243);text-decoration-style:initial;text-decoration-color:initial;display:inline;float:none">Park Tsai</span><br></div><div class="gmail_extra"><br><div class="gmail_quote">2018-08-08 2:04 GMT+08:00 Steve Holden <span dir="ltr"><<a href="mailto:steve@holdenweb.com" target="_blank">steve@holdenweb.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-size:small">Hi there,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Good to see you on python-dev. It's always good to see people getting excited about helping with Python's development.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">The changes you suggest are, unless I've missed something, purely cosmetic - affecting readability only. This implies that you feel the code as it stands isn't as readable as it could be. You must admit that "it looks messy" is a matter of opinion, and alone isn't much of a justification for making changes to a project that will reach its end of life in less than eighteen months.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">The code in the standard library is mostly fairly well-scrutinised, and as PEP 8 reminds us, change made for purely stylistic reasons threatens to introduce new bugs.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">It's not obvious how much of the developer documentation you've seen, so it might be worth mentioning <a href="https://devguide.python.org/" target="_blank">https://devguide.<wbr>python.org/</a> as a good starting point for anyone wanting to contribute.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">regards</div><div class="gmail_default" style="font-size:small"> Steve</div></div><div class="gmail_extra"><br clear="all"><div><div class="m_6485140121288454235gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Steve Holden<br></div></div></div>
<br><div class="gmail_quote"><div><div class="h5">On Tue, Aug 7, 2018 at 8:00 AM, 蔡銘峯 <span dir="ltr"><<a href="mailto:parktasi@gmail.com" target="_blank">parktasi@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr">Hello everybody, <br>I am Park Tsai. I want to refactor __get_builtin_constructor on hasklib.py of python 2.7 (<a href="https://github.com/python/cpython/blob/2.7/Lib/hashlib.py#L72" target="_blank">https://github.com/python/cpy<wbr>thon/blob/2.7/Lib/hashlib.py#<wbr>L72</a>). <br>This is the first time that I try to refactor code of CPython on GitHub, so I am very excited. <br><br>This is __get_builtin_constructor code on hasklib.py ,as follows. <br><br>def __get_builtin_constructor(name<wbr>):<br> try:<br> if name in ('SHA1', 'sha1'):<br> import _sha<br> return _sha.new<br> elif name in ('MD5', 'md5'):<br> import _md5<br> return _md5.new<br> elif name in ('SHA256', 'sha256', 'SHA224', 'sha224'):<br> import _sha256<br> bs = name[3:]<br> if bs == '256':<br> return _sha256.sha256<br> elif bs == '224':<br> return _sha256.sha224<br> elif name in ('SHA512', 'sha512', 'SHA384', 'sha384'):<br> import _sha512<br> bs = name[3:]<br> if bs == '512':<br> return _sha512.sha512<br> elif bs == '384':<br> return _sha512.sha384<br> except ImportError:<br> pass # no extension module, this hash is unsupported.<br><br> raise ValueError('unsupported hash type ' + name)<br><br><br>When I read this code, it looks messy, so I want to refactor it and make it become more clearly . <br><br>Then, it will be like this <br><br>def get_builtin_constructor(name):<br> try:<br> if name[:3] in ('SHA','sha'):<br> if(name[3:]=='1'):<br> import _sha<br> return _sha.new<br><br> elif (name[3:] == '224'):<br> import _sha256<br> return _sha256.sha224<br><br> elif (name[3:] == '256'):<br> import _sha256<br> return _sha256.sha256<br><br> elif (name[3:] == '384'):<br> import _sha512<br> return _sha512.sha384<br><br> elif (name[3:] == '512'):<br> import _sha512<br> return _sha512.sha512<br> elif name in ('MD5', 'md5'):<br> import _md5<br> return _md5.new<br><br> except ImportError:<br> pass # no extension module, this hash is unsupported.<br><br> raise ValueError('unsupported hash type ' + name)<br><br>I will be grateful for any help you can provide. I really appreciate any feedback you can offer! <br><br>Best regards, <br>Park Tsai !!<br></div>
<br></div></div><span class="">______________________________<wbr>_________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/listinfo/python-dev</a><br></span>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/steve%40holdenweb.com" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/options/python-dev/steve%<wbr>40holdenweb.com</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>