Suggested coding style

Stephen Hansen me+list/python at ixokai.io
Tue Oct 4 02:24:27 EDT 2011


On 9/30/11 6:54 AM, rantingrick wrote:
> a misplaced and rarely used functionality of the stdlib.

Have you tried putting "\.zfill\(" and selecting Python in
google.com/codesearch?

It seems to have quite a few users, among only openly available code.
Considering there is a much larger body of code that isn't openly
available, its not hard to extrapolate from the search. (Then again, the
Python Community is made up of only people on this list! Everyone knows
that.)

Sure, you can use format strings, but that is a significantly more
complicated thing to do.

It may not be /common/, but is not at all unusual for one to have in a
string a number that they want to line up numerically with zeros. You
may not have had to do it a lot. But, golly, you are not a
representative sample of the world. Your code, your projects, the things
you have done, are not a representative sample of all the Python code,
projects, and things people have done with Python out there.

The "zfill" may not be a super wonderful function, used by many in most
places. But its there, its simple, its clear what it does.

Removing it means that anyone who wants to do what it did, now have to
learn a fairly complex mini-language, even if perhaps that is the only
time they will /ever/ need to use said language. That's a burden which
is just, frankly, silly.

Its nice that the format mini-language is powerful. But its nice that
there are also simple, clear, direct primitives people can use to
accomplish simple, fairly common needs.

-- 

   Stephen Hansen
   ... Also: Ixokai
   ... Mail: me+list/python (AT) ixokai (DOT) io
   ... Blog: http://meh.ixokai.io/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 487 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20111003/0ae1614a/attachment.sig>


More information about the Python-list mailing list