TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Google Python Style Guide

49 pointsby iamelgringoabout 15 years ago

6 comments

tvonabout 15 years ago
A "how this differs from PEP8" summary would be useful to me, assuming it differs.
评论 #1311459 未加载
评论 #1311799 未加载
ablealabout 15 years ago
&#62; Indent your code blocks with 4 spaces.<p>I had this notion it formerly was 2 spaces (too little, IMH-once-bitten-O). Anyone know when it changed, if it did ?<p>P.S. In <a href="http://groups.google.com/group/django-developers/msg/f6a86d135fb2968f" rel="nofollow">http://groups.google.com/group/django-developers/msg/f6a86d1...</a> , back in Aug.2008, GvR says "Most of it [Google's unpublished internal Python style] is simply PEP-8 with 2-space indents."<p>(I dislike 2 spaces, once bitten by missing an indentation bug. I try to stick to 80 columns - both for print and side-by-side on screen - and think that more than 4 or 5 levels of indentation is "doing it wrong".)
评论 #1311263 未加载
评论 #1311644 未加载
评论 #1311269 未加载
sigzeroabout 15 years ago
Within each grouping, imports should be sorted lexicographically, ignoring case, according to each module's full package path.<p><pre><code> import foo from foo import bar from foo.bar import baz from foo.bar import Quux from Foob import ar </code></pre> That seems kind of time consuming...
评论 #1311717 未加载
njharmanabout 15 years ago
&#62; which should inherit from the built-in Exception class<p>I hate that. should inherit from StandardError IMNSHO. It's a quibble though and a pointless one until the standard library follows that. (which it never will...)<p>&#62; Use the "implicit" false if at all possible.<p>Is so wrong, for the listed caveat reasons and more. It's the opposite of readability to me. Similar issues with the use default iterators. If my loop is expecting a dictionary and to iterate over it's keys I really want the "foo has no method keys" error rather than looping over a list and creating hard to discover/understand bug.
1amzaveabout 15 years ago
I enjoyed this bit of example code:<p><pre><code> x = '%s, %s!' % (imperative, expletive) </code></pre> A decidedly familiar sentence structure...
Qzabout 15 years ago
I don't know if this is just me, but the page looks super ugly on Firefox.
评论 #1311752 未加载