Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #48915
| Path | csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.fsmpi.rwth-aachen.de!news.unit0.net!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'skip:% 20': 0.09; 'subject:question': 0.10; 'api': 0.11; 'python': 0.11; 'wrote': 0.14; 'code?': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'splitting': 0.16; 'terribly': 0.16; 'wrote:': 0.18; 'module': 0.19; 'rules': 0.22; 'header:User-Agent:1': 0.23; 'library,': 0.24; 'question': 0.24; 'logging': 0.26; 'posts': 0.26; 'code:': 0.26; 'header:X -Complaints-To:1': 0.27; 'code': 0.31; 'lines': 0.31; 'breaking': 0.31; 'screen': 0.34; 'skip:s 30': 0.35; 'there': 0.35; 'really': 0.36; 'hi,': 0.36; 'similar': 0.36; 'to:addr:python-list': 0.38; 'fact': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'goal': 0.75; 'eyes': 0.78; 'ok?': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Peter Otten <__peter__@web.de> |
| Subject | Re: n00b question on spacing |
| Date | Sat, 22 Jun 2013 07:46:35 +0200 |
| Organization | None |
| References | <CAJ=2b07ETuSuo2+3Xu6vMOJA+q1JwUFTezO3LaYLG8wXd+FLBQ@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1" |
| Content-Transfer-Encoding | 7Bit |
| X-Gmane-NNTP-Posting-Host | p5084bd76.dip0.t-ipconnect.de |
| User-Agent | KNode/4.7.3 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3686.1371879937.3114.python-list@python.org> (permalink) |
| Lines | 31 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1371879937 news.xs4all.nl 15949 [2001:888:2000:d::a6]:44601 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:48915 |
Show key headers only | View raw
Yves S. Garret wrote:
> 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?
You can move the goal posts and change your API (to one similar to the
logging module in the standard library, for example):
log.debug(
"Wrote item to MongoDB database %s/%s",
settings["MONGODB_DB"],
settings["MONGODB_COLLECTIONS"],
spider=spider)
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: n00b question on spacing Peter Otten <__peter__@web.de> - 2013-06-22 07:46 +0200
csiph-web