Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'parameters': 0.04; '21,': 0.07; 'string': 0.09; '%s"': 0.09; 'friday,': 0.09; 'notes:': 0.09; 'skip:% 20': 0.09; 'subject:question': 0.10; 'cc:addr:python-list': 0.11; 'python': 0.11; 'wrote': 0.14; 'code?': 0.16; 'concatenate': 0.16; 'length,': 0.16; 'pep8': 0.16; 'spacing': 0.16; 'splitting': 0.16; 'terribly': 0.16; 'url:pep-0008': 0.16; 'url:peps': 0.16; 'appropriate': 0.16; '<': 0.19; 'settings': 0.22; 'email addr:gmail.com>': 0.22; 'rules': 0.22; 'cc:addr:python.org': 0.22; 'questions:': 0.24; 'url:dev': 0.24; 'url:gt': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'code:': 0.26; 'header:In-Reply-To:1': 0.27; 'url:mailman': 0.30; 'code': 0.31; 'lines': 0.31; 'breaking': 0.31; 'ray': 0.31; 'text': 0.33; 'url:python': 0.33; '-----': 0.33; 'becomes': 0.33; 'style': 0.33; 'screen': 0.34; 'basic': 0.35; 'skip:s 30': 0.35; 'something': 0.35; 'there': 0.35; 'really': 0.36; 'url:listinfo': 0.36; 'hi,': 0.36; 'url:org': 0.36; 'example,': 0.37; 'so,': 0.37; 'two': 0.37; 'email addr:python.org': 0.37; 'fact': 0.38; 'subject:': 0.39; 'url:mail': 0.40; 'break': 0.61; 'matter': 0.61; 'personal': 0.63; 'more': 0.64; 'email name:python-list': 0.65; 'to:addr:gmail.com': 0.65; 'within': 0.65; 'header:Reply-To:1': 0.67; 'eyes': 0.78; 'everything.': 0.84; 'ok?': 0.84; '2013': 0.98 X-Virus-Scanned: amavisd-new at appropriatesolutions.com Date: Fri, 21 Jun 2013 17:48:54 -0400 (EDT) From: Ray Cote To: "Yves S. Garret" In-Reply-To: Subject: Re: n00b question on spacing MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_2778_33080709.1371851333304" X-Originating-IP: [64.139.71.205] X-Mailer: Zimbra 7.2.3_GA_2872 (Zimbra Desktop/7.2.2_11951_Mac) Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ray Cote List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 123 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1371851743 news.xs4all.nl 15879 [2001:888:2000:d::a6]:39693 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:48885 ------=_Part_2778_33080709.1371851333304 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit ----- Original Message ----- > From: "Yves S. Garret" > To: python-list@python.org > Sent: Friday, June 21, 2013 5:17:28 PM > Subject: n00b question on spacing > 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? > -- > http://mail.python.org/mailman/listinfo/python-list Hi Yves: PEP8 is your definitive guide for style questions: and this is an interesting set of notes: Basic rule is to break within parenthesis -- after that it becomes a matter of personal taste/style. In your specific example, I would do something like: log.msg( "Item wrote to MongoDB database %s %s" % ( settings['MONGODB_DB'], settings['MONGODB_COLLECTION]), level=log.DEBUG, spider=spider) Though you might want to: a) start your string right after the log.msg( b) put more than one settings on the same line c) put the last two parameters on the same line. I find that once I start breaking up lines for length, that I prefer to break up everything. Also remember when entering long lines of text that strings concatenate within parenthesis. So, ("a, b, c" "d, e, f" "g, h, i") Is the same as ("a, b, cd, e, fg, h, i") --Ray -- Ray Cote, President Appropriate Solutions, Inc. We Build Software 603.924.6079 ------=_Part_2778_33080709.1371851333304 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable <= div style=3D'font-family: arial,helvetica,sans-serif; font-size: 10pt; colo= r: #000000'>

From: "Yves S. Ga= rret" <yoursurrogategod@gmail.com>
To: python-list@python.o= rg
Sent: Friday, June 21, 2013 5:17:28 PM
Subject: n00b= question on spacing

Hi, I have a qu= estion 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=3Dlog.= DEBUG, spider=3Dspider)

Given the fact that it goes off very far to the right on my scree= n is not terribly
pleasing to my eyes (and can be rude for other develo= pers).

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=3Dlog.DEBUG, spider=3Dspider)

Is this ok?  Are the= re any rules in Python when it comes to breaking up long lines of
code?=

--
http://mail.python.org/mailman/listinfo/python-list

Hi Yves:
PEP8 is your definitive guide for style questions:
&= nbsp; <http://www.python.org/dev/peps/pep-0008/>

and this is a= n interesting set of notes:
  <http://stackoverflow.com/question= s/5931297/how-would-you-properly-break-this-line-to-match-pep8-rules>

Basic rule is to break within parenthesis -- after that it becomes= a matter of personal taste/style.

In your specific example, I would= do something like:
log.msg(
    "Item wrote to MongoD= B database %s %s" % (
settings= ['MONGODB_DB'],
settings['MONGODB_COLLECTION]),
level=3Dl= og.DEBUG,
spider=3Dspider)

Though you might want to:
a) st= art your string right after the log.msg(
b) put more than one settings o= n the same line
c) put the last two parameters on the same line.

= I find that once I start breaking up lines for length, that I prefer to bre= ak up everything.

Also remember when entering long lines of text th= at strings concatenate within parenthesis.
So,
("a, b, c"
"d, e,= f"
"g, h, i")

Is the same as ("a, b, cd, e, fg, h, i")

-= -Ray

--
Ray Cote, President=
Appropriate Solutions, Inc.
We Build Software
603.924.6079
------=_Part_2778_33080709.1371851333304--