Suggested coding style

Prasad, Ramit ramit.prasad at jpmorgan.com
Fri Sep 30 12:06:19 EDT 2011


>May I suggest a[n] email client that can group mailing list threads?

Please do. Bonus points if it handles threading in a Gmail-like style.

Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423



-----Original Message-----
From: python-list-bounces+ramit.prasad=jpmorgan.com at python.org [mailto:python-list-bounces+ramit.prasad=jpmorgan.com at python.org] On Behalf Of Devin Jeanpierre
Sent: Thursday, September 29, 2011 6:07 PM
To: rantingrick
Cc: python-list at python.org
Subject: Re: Suggested coding style

> However, as you use the new format method you will come to appreciate
> it. It's an adult beverage with an acquired taste. ;-)

Yeah. It's a much more difficult to read thing, but once you learn how
to write it it flows faster.

Of course, I never managed to learn how to write it...

I would suggest that rather than being "complicated" it is "dense".

> PS: Has anyone noticed all the off topic chatter about religion and
> feelings? Since the main subject of this thread is about zfill i can't
> help but wonder if the minions where sent out to present a distraction
> with "scripted" pseudo arguments. Just an observation.

Devin

On Thu, Sep 29, 2011 at 6:56 PM, rantingrick <rantingrick at gmail.com> wrote:
> On Sep 29, 5:12 pm, Ian Kelly <ian.g.ke... at gmail.com> wrote:
>> On Thu, Sep 29, 2011 at 6:23 AM, rantingrick <rantingr... at gmail.com> wrote:
>> > A specific method for padding a string with ONLY zeros is ludicrous
>> > and exposes the narrow mindedness of the creator. The only thing worse
>> > than "zfill" as a string method is making zfill into built-in
>> > function! The ONLY proper place for zfill is as an option in the
>> > str.format() method.
>>
>> > py> "{0:zf10}".format(1234) -> "00000000001234"
>>
>> Agree that zfill seems to be redundant with str.format, although your
>> suggested syntax is atrocious, especially since a syntax already
>> exists that fits better in the already-complicated format specifier
>> syntax.
>
> It's interesting that you find the format specifier "complicated". I
> will admit that upon first glance i lamented the new format method
> spec and attempted to cling to the old string interpolation crap.
> However, as you use the new format method you will come to appreciate
> it. It's an adult beverage with an acquired taste. ;-)
>
> One thing that may help format noobs is to look at the spec as two
> parts; the part before the colon and the part after the colon. If you
> break it down in this manner the meaning starts to shine through. I
> will agree, it is a lot of cryptic info squeezed into a small space
> HOWEVER you would no want a verbose format specification.
>
> But i wholeheartedly agree with you points and i would say the zfill
> method has no future uses in the stdlib except for historical reasons.
> We should deprecate it now.
>
>
>> "{0:=010d}".format(1234) -> "0000001234"
>>
>> There are a couple of warts with the existing implementation, however:
>>
>> 1) str.zfill() operates on strings; the .format() syntax operates on
>> numeric types.  I would suggest that the "=" fill alignment in format
>> specifiers should be extended to do the same thing as zfill when given
>> a string.
>
> EXACTLY!
>
> PS: Has anyone noticed all the off topic chatter about religion and
> feelings? Since the main subject of this thread is about zfill i can't
> help but wonder if the minions where sent out to present a distraction
> with "scripted" pseudo arguments. Just an observation.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list

This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  


More information about the Python-list mailing list