impala-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Brown <mi...@cloudera.com>
Subject Re: Python string formatting
Date Tue, 31 Jan 2017 16:59:10 GMT
Thanks. I made some comments on the review, but I see now I should
probably share my general view here.

My general view is, if we are going to codify our Python style guide,
I would rather we codify style conventions that are closer to standard
Python style conventions, rather than codify what is currently done. I
am willing to keep 2-space indents and 90-char lines, but I don't
think anything else should be part of the conventions when those
conventions involves ignoring PEP-008. My instinct tells me the Python
conventions weren't conventions at all, but came up organically
without regard to actually reading conventions or using tooling.
Otherwise, we'd have already had a Python style guide, right?

If the concern is "But there are too many noisy errors if I am editing
an existing, large file, so we should ignore these anyway", something
like this is possible:

git diff | flake8 --diff

This will only show PEP-008 problems on changed code, not whole files.



On Mon, Jan 30, 2017 at 3:20 PM, Lars Volker <lv@cloudera.com> wrote:
> Cool, thanks Michael for the reply. I added a section on Python to the Impala
> Style Guide
> <https://cwiki.apache.org/confluence/display/IMPALA/Impala+Style+Guide>.
> Please feel free to edit it or let me know if I should make changes. I will
> also send out a review to add a .pep8rc file to the repository.
>
> On Fri, Jan 27, 2017 at 11:56 PM, Michael Brown <mikeb@cloudera.com> wrote:
>
>> I prefer str.format() over the % operator, because:
>>
>> https://docs.python.org/2.7/library/stdtypes.html#str.format
>>
>> "This method of string formatting is the new standard in Python 3, and
>> should be preferred to the % formatting described in String Formatting
>> Operations in new code."
>>
>> Without an Impala Python style guide, I tend to use what I see on
>> docs.python.org, modulo our 2-space indent and 90-char line policy.
>>
>>
>> On Fri, Jan 27, 2017 at 2:44 PM, Lars Volker <lv@cloudera.com> wrote:
>> > Hi All,
>> >
>> > do we have a strong preference for either old style or new style string
>> > formatting in Python?
>> >
>> > "Hello %s!" % ("world") *vs* "Hello {0}!".format("world")
>> >
>> > The Impala Style Guide
>> > <https://cwiki.apache.org/confluence/display/IMPALA/Impala+Style+Guide>
>> doesn't
>> > mention Python at all.
>> >
>> > Thanks, Lars
>>

Mime
View raw message