Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #6239

Re: Newbie string questions

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <chris@theguidrys.us>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.020
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'string.': 0.04; 'subject:string': 0.09; '25,': 0.12; 'debugging': 0.14; 'wrote:': 0.14; 'cc:name:python list': 0.16; 'message- id:@glegroupsg2000goo.googlegroups.com': 0.16; 'reply- to:addr:comp.lang.python': 0.16; 'repr()': 0.16; 'stumping': 0.16; 'subject:Newbie': 0.16; 'subject:questions': 0.16; 'to:addr:comp.lang.python': 0.16; 'wednesday,': 0.16; 'cc:addr :python-list': 0.17; 'header:In-Reply-To:1': 0.21; "haven't": 0.22; 'cc:2**0': 0.22; 'received:209.85.220': 0.25; 'classes': 0.26; 'string': 0.26; 'cc:addr:python.org': 0.30; 'from:addr:chris': 0.30; 'objects.': 0.30; 'seem': 0.32; "can't": 0.32; 'does': 0.33; 'header:User-Agent:1': 0.35; 'do?': 0.35; 'considered': 0.36; 'received:google.com': 0.37; 'useful': 0.37; 'received:209.85': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'should': 0.39; 'received:209': 0.39; 'format': 0.40; 'your': 0.60; 'order': 0.62; 'to:addr:googlegroups.com': 0.63; 'overload': 0.67; 'header:Reply-To:1': 0.72; 'reply-to:no real name:2**0': 0.72; 'reply-to:addr:googlegroups.com': 0.73; 'anywhere.': 0.84; 'surface': 0.91
Newsgroups comp.lang.python
Date Wed, 25 May 2011 06:13:34 -0700 (PDT)
In-Reply-To <mailman.2071.1306328771.9059.python-list@python.org>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=76.24.107.129; posting-account=m4aVZQoAAADWs-Sq2Sd8RxAr4pIsezyO
User-Agent G2/1.0
X-Google-Web-Client true
MIME-Version 1.0
Subject Re: Newbie string questions
From Chris Guidry <chris@theguidrys.us>
To comp.lang.python@googlegroups.com
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
Cc Python list <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
Reply-To comp.lang.python@googlegroups.com
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>
Message-ID <mailman.2073.1306329222.9059.python-list@python.org> (permalink)
Lines 13
NNTP-Posting-Host 82.94.164.166
X-Trace 1306329223 news.xs4all.nl 49042 [::ffff:82.94.164.166]:42956
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:6239

Show key headers only | View raw


On Wednesday, May 25, 2011 9:06:02 AM UTC-4, Matty Sarro wrote:
> can't seem to find some of the items in the documentation. Right now
> what is stumping me... what exactly does %r do? I can't find it in the
> documentation anywhere.

Matty, %r in a format string is very much like %s.  %s calls str(your_object) in order to produce the resulting string.  %r calls repr(your_object).  Generally, you'd want to use %s for strings that will surface to a user, while %r is great for debugging and logging.

Also, if you haven't come across repr(), you should be able to find that in the docs; it's also considered good practice to overload repr() in your own classes in order to provide a useful representation for your objects.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Newbie string questions Chris Guidry <chris@theguidrys.us> - 2011-05-25 06:13 -0700

csiph-web