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


Groups > comp.lang.python > #25830

Re: default repr?

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news-out1.kabelfoon.nl!newsfeed.kabelfoon.nl!bandi.nntp.kabelfoon.nl!feed.xsnews.nl!border-1.ams.xsnews.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.008
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'output': 0.04; 'method,': 0.07; 'python': 0.09; 'parameter.': 0.09; 'repr': 0.09; 'tuple': 0.09; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:default': 0.16; 'threw': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'received:209.85.214.174': 0.21; 'lets': 0.22; 'defined': 0.22; 'header:In-Reply-To:1': 0.25; 'skip:" 20': 0.26; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'dan': 0.29; 'shoot': 0.29; 'class': 0.29; 'getting': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'list': 0.35; 'subject:?': 0.35; 'received:209.85': 0.35; 'there': 0.35; "wasn't": 0.36; 'method': 0.36; 'received:209': 0.37; 'well.': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'skip:o 20': 0.38; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'header:Received:5': 0.40; 'first': 0.61; 'limit': 0.65; 'jul': 0.65; 'yourself': 0.77; 'everything.': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=hzy96/1gXhTQ+RA4JrADKdnxcKJURE/FRLcJBcmIUOk=; b=dO7ABk/iSc6DfL8+32Z5da2gqAfJfrwKmINVJJr6krBl0zFDhsrfLfap8cy+6NPUIr I6QQkIxsiWw/H+/bvTJIDNsivck3eCC4XOUh7Mvbc6BRXbIWXIEWvp4n3btzGxgVhFqh a7Smjbw1kRnBTlFEXBtPWsDLOPQrBuKKKjKSOaLaYbzkVZGDPXo8NpA4GSiqTcCBQ7IV xRv/vJsIjaDkwrEcY3w6TGY/e9vv0YA0vBQSslSbRTDr9XG9iCyvjOPAIOcXTfCiLxMt B1OU2NToS38eo8SPImIUQKIDIs7lguFeVHoAbGi7yYE95OwKmdW7NRkZR8QQhjB1NEVk 0z8Q==
MIME-Version 1.0
In-Reply-To <CAGGBd_oD9tT6Ej0NdsPF7-VRda1k_GQmUQAuutg-eO+XbdYD3Q@mail.gmail.com>
References <CAGGBd_oD9tT6Ej0NdsPF7-VRda1k_GQmUQAuutg-eO+XbdYD3Q@mail.gmail.com>
Date Mon, 23 Jul 2012 08:54:00 +1000
Subject Re: default repr?
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
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.2444.1342997643.4697.python-list@python.org> (permalink)
Lines 15
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1342997643 news.xs4all.nl 6939 [2001:888:2000:d::a6]:40898
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:25830

Show key headers only | View raw


On Mon, Jul 23, 2012 at 8:48 AM, Dan Stromberg <drsalists@gmail.com> wrote:
> If a class has defined its own __repr__ method, is there a way of getting
> the default repr output for that class anyway?

Methods are just functions, and you can call any method of any class
with any object as its first parameter.

object.__repr__(some_object)

Though this mightn't work with everything. I wasn't able to paint a
list as a tuple - "tuple.__repr__([1,2,3])" threw a TypeError. Oh
well. There's a limit to the ways Python lets you shoot yourself in
the foot.

ChrisA

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


Thread

Re: default repr? Chris Angelico <rosuav@gmail.com> - 2012-07-23 08:54 +1000
  Re: default repr? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-23 00:24 +0000
    Re: default repr? Chris Angelico <rosuav@gmail.com> - 2012-07-23 10:29 +1000
      Re: default repr? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-23 01:40 +0000
    Re: default repr? Devin Jeanpierre <jeanpierreda@gmail.com> - 2012-07-22 20:44 -0400

csiph-web