Suggested coding style

MRAB python at mrabarnett.plus.com
Sat Sep 24 21:03:31 CEST 2011


On 24/09/2011 18:31, Passiday wrote:
> Hello,
>
> I have started to code random stuff in Python only recently, still
> lots to learn. So please bear with me if my question sounds like rant.
>
> I have been coding in many other languages, most of the time it was
> Java and C#. I don't like the function mess of PHP (ie, loads and
> loads of functions without any namespaces etc), but I'd like to think
> that Python is different.
>
> In my brief coding experience I have stumbled upon Python zfill(width)
> method, and I thought, really, do you have to include such a narrow-
> purpose method in the basic method set? Perhaps there are more such
> methods that are nice when you need them, but then again, you don't
> put all the possible methods in the standard set.
>
> Perhaps there is reason such method is in the basic library, and my
> complaints are unbased? Or, perhaps the language is on course to bloat
> out and get filled with tens and hundreds of special-purpose methods
> that render the language structure chaotic?
>
Considering that Python has been around for 20 years, there's not much
bloat. Most of the risk of that was early on, when any interest in the
language might have been welcomed. Now that its use has grown, it can
be more choosy.

.zfill does have its uses:

 >>> "-1".rjust(4, "0")
'00-1'
 >>> "-1".zfill(4)
'-001'



More information about the Python-list mailing list