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


Groups > comp.lang.python > #25830

Re: default repr?

References <CAGGBd_oD9tT6Ej0NdsPF7-VRda1k_GQmUQAuutg-eO+XbdYD3Q@mail.gmail.com>
Date 2012-07-23 08:54 +1000
Subject Re: default repr?
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.2444.1342997643.4697.python-list@python.org> (permalink)

Show all headers | 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