Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news-out.readnews.com!transit4.readnews.com!panix!gordon From: John Gordon Newsgroups: comp.lang.python Subject: Re: n00b question on spacing Date: Fri, 21 Jun 2013 21:47:06 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Lines: 30 Message-ID: References: NNTP-Posting-Host: panix3.panix.com X-Trace: reader2.panix.com 1371851226 5095 166.84.1.3 (21 Jun 2013 21:47:06 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Fri, 21 Jun 2013 21:47:06 +0000 (UTC) User-Agent: nn/6.7.3 Xref: csiph.com comp.lang.python:48884 In "Yves S. Garret" writes: > Hi, I have a question about breaking up really long lines of code in Python. > I have the following line of code: > log.msg("Item wrote to MongoDB database %s/%s" %(settings['MONGODB_DB'], > settings['MONGODB_COLLECTION']), level=log.DEBUG, spider=spider) > Given the fact that it goes off very far to the right on my screen is not > terribly pleasing to my eyes (and can be rude for other developers). > I was thinking of splitting it up like so: > log.msg("Item wrote to MongoDB database %s/%s" > %(settings['MONGODB_DB'], settings['MONGODB_COLLECTION']), > level=log.DEBUG, spider=spider) > Is this ok? Are there any rules in Python when it comes to breaking up > long lines of code? There are guidelines in the PEP8 document: http://www.python.org/dev/peps/pep-0008/ Check out the section entitled 'Code lay-out'. -- John Gordon A is for Amy, who fell down the stairs gordon@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies"